How to move a folder with subfolders and files to Laravel using Storage ?

 Storage::move('old/file1.jpg', 'new/file1.jpg'); 

It seems to only work with files.

    1 answer 1

    Storage does not support folder transfer. Need to use moveDirectory

     use Illuminate\Filesystem\Filesystem; $file = new Filesystem(); $file->moveDirectory('../storage/app/public/old_folder', '../storage/app/public/new_folder'); 

    Documentation link

    • for some reason doesn't work in the answer - Pupsik
    • @Pupsik you gave the exact same answer) How can it not work) - Alexander Semikashev
    • @Pupsik well, and I took the code from the current project. it's okay - Alexander Semikashev
    • I have in the storage / app / public / 0'.Auth :: user () -> id folder there are 5 photos and a small folder in which there are also 5 miniatures, but it does not move - Pupsik
    • @Pupsik turn on debag and see what kind of error. Also check if there are rights to work with folders. But the code should work. - Alexander Semikashev