Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

magero's avatar

Upload to Digital ocean spaces copies files to public folder

My method for uploading files to digital ocean spaces works perfectly but the files are uploaded both in project's public folder and spaces directory. I want to only upload files to digital ocean spaces and keep none in the project directory how can I go about this??

here is how my upload function looks like

if ($file = $request->hasFile('display_image')) {
            $post_image = $request->file('display_image');
            $filename = $post_image->getClientOriginalName();
            $compressed_image = $this->compressImage($post_image, $filename);
            $path = Storage::putFileAs('uploads/displayimage/'.$post->post_id, $compressed_image, 'public', 'spaces');
            $post->display_image = $filename;
        }

here is my file system configuration

'spaces' => [
            'driver' => 's3',
            'key' => env('SPACES_ACCESS_KEY_ID'),
            'secret' => env('SPACES_SECRET_ACCESS_KEY'),
            'region' => env('SPACES_DEFAULT_REGION'),
            'bucket' => env('SPACES_BUCKET'),
            'endpoint' => env('SPACES_ENDPOINT'),
            'url' => env('SPACES_URL'),
            'visibility' => 'public'
        ]
0 likes
3 replies
Snapey's avatar

probably not copying to both. More likely you have a symlink in place

magero's avatar

yes i had created a symlink but along the line decided to have the files store on spaces, don't know how to prevent it from uploading to public folder

magero's avatar

@Snapey its uploading to both public folder (on the project) and spaces folder....i want it to upload only to spaces

Please or to participate in this conversation.