Moving files using laravel

Posted April 14, 2020 5.4k views
DigitalOcean Spaces

I have a issue with moving images on digitalocean. I’m using the following code:

Storage::disk('do-spaces')->move('xxx/uploads/temp/'.$image_name_request, 'xxx/dps/images/'.$image->image_filename); 


I did the following checks:

  • checked if file in temp folder exists -> get back true
  • both $image_name_request and $image->image_filename are set
  • Code does not give an error but nothing is changed on digitalocean spaces.
  • check if dps/image file exists gives -> false

Any idea what i’m doing wrong or a way to debug this?

edited by MattIPv4
1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers

Hi @mbodo,

This will require some troubleshooting.

Firstly, what I see, it’s possible Laravel doesn’t recognize ‘do-spaces’ as a configured disk.

Add DigitalOcean Spaces as a configured disk in Laravel

  1. Istall via Composer Flysystem Adapter for AWS SDK V3
composer require league/flysystem-aws-s3-v3
  1. Add the following disk to the array located in Config/filesystems.php file :

    do_spaces' => [     
    'driver' => 's3',     
    'key' => env('DO_SPACES_KEY'),     
    'secret' => env('DO_SPACES_SECRET'),     
    'endpoint' => env('DO_SPACES_ENDPOINT'),     
    'region' => env('DO_SPACES_REGION'),     
    'bucket' => env('DO_SPACES_BUCKET'), 
  2. Add the following variables to your .env file

    DO_SPACES_SECRET= (example) DO_SPACES_REGION=SFO2 (example) 

    Once you’ve added the above, you should be able to use the 's3’ driver for your disk.


  • Dear KDSys,

    Thanks for the reaction. The strange thing is that the file system is in place. I did the following to test the system:

    storing the file:

    $filename = sha1(time()).$request->file('file')->getClientOriginalName();
    $request->file('file')->storeAs('xxx/uploads/temp/',$filename, 'do-spaces');
    Storage::disk('do-spaces')->setVisibility('xxx/uploads/temp/'.$filename, 'public');

    Checking if the file exists"

    $exists = Storage::disk('do-spaces')->

    gives true

    Trying to move the file:

    Storage::disk('do-spaces')->move('xxx/uploads/temp/'.$image_name_request, 'ligplaats/uploads/temp/'.$image->image_filename);  

    Did a visual check and checked by this code:

    $exists = Storage::disk('do-spaces')->exists('ligplaats/uploads/temp/'.$image->image_filename);

    gives false.

    Any idea what can be the issue?

    thanks for the reply.


We were not able to fix the move command. We solved it by uploading to the new location after that deleting the file from the old location.

I am also having an issue with this.
I’ve been using laravel’s Storage system with DO spaces for over a year now, it is storing files no problem.
BUT when I try to Storage::move(‘folder1’, 'folder2’) it executes just fine, but the directory has not been renamed. It’s like the command does nothing.
I also tried Storage::rename.

Also; Storage::copy() doesn’t seem to do anything.

Storage::makeDirectory() and Storage::deleteDirectory() work though.

With regards to moving/copying directories, this is a useful link: