Laravel, unable to copyDirectory or moveDirectory

前端 未结 2 718
不知归路
不知归路 2021-01-16 12:33

Currently I having problem with Laravel cannot use moveDirectory and copyDirectory however makeDirectory or deleteDirectory works fine, the code as follow:

&         


        
2条回答
  •  遥遥无期
    2021-01-16 13:30

    I guess moveDirectory is not available under Storage. Try with below code

    import file system first

    use Illuminate\Filesystem\Filesystem;
    

    after that create a new instance and move directory. Path is relative to index.php I guess.

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

    Edited

    You can bypass instance creation with method injection

    public function update(Request $request,Filesystem $file, $id)
    

提交回复
热议问题