Laravel 5.4: how to delete a file stored in storage/app

后端 未结 8 1576
臣服心动
臣服心动 2020-12-30 00:22

I want to delete a file that is stored in storage/app/myfolder/file.jpg. I have tried the following codes but none of this works:

use File    
$file_path = u         


        
相关标签:
8条回答
  • 2020-12-30 00:59

    Try:

    unlink(public_path('uploads\users'). DIRECTORY_SEPARATOR .$user->image);
    

    This worked for me..

    0 讨论(0)
  • 2020-12-30 01:00

    Use storage

    //demo 
    use Illuminate\Support\Facades\Storage;
    
    Storage::delete($filename);
    

    Another way,

    unlink(storage_path('app/folder/'.$filename));
    
    0 讨论(0)
提交回复
热议问题