简体   繁体   English

Laravel 5.1 - 无法删除文件

[英]Laravel 5.1 - Unable to delete file

I have the following code: 我有以下代码:

Storage::delete(public_path($file->path));

But I get error: 但我得到错误:

File not found at path: C:\wamp\www\laravel\acme\public\img/logos/1486846424_acme.gif

When I check the directory I can see the file is there so why I'm I unable to delete it. 当我检查目录时,我可以看到文件在那里,所以为什么我无法删除它。 I've tried the php unlink function too and I get same error. 我也试过了php unlink函数,我得到了同样的错误。

Works if I use: 如果我使用:

File::delete(public_path($file->path));

Seems like to delete files from the public path you have to use the above - File::delete and to delete files from the storage path you have to use below - Storage::delete: 似乎要删除您必须使用上述公共路径的文件 - File :: delete并从以下必须使用的存储路径中删除文件 - Storage :: delete:

Storage::delete(public_path($file->path));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM