Storage::move giving “File not found at path:”

1.6k Views Asked by At

I am trying to move an image from one folder into another folder by using:

Storage::move(storage_path('app/public/temporary/').$imageName, storage_path('app/public/profilePic/'.$imageName));

But when i run it gave me the error:

File not found at path: home/vagrant/code/avida/storage/app/public/temporary/5bfb7272e9dc9.download.jpeg

i google and found the following solution:

Storage::disk('local')->move(storage_path('app/public/temporary/').$imageName, storage_path('app/public/profilePic/'.$imageName));

but then it gave another error:

Method 'disk' not found in \Illuminate\Support\Facades\Storage

Can anyone please help me how can i move this file ? Thank you

1

There are 1 best solutions below

0
On

Storage class operate in storage directory so there is no need to use storage_path() helper.

Change your code to the one below:

Storage::move('public/temporary/'.$imageName, 'public/profilePic/'.$imageName);

I hope that helps :)