我无法使用laravel Storage::delete
功能删除文件。
我的图片存储代码是:
$logoPath = $request->file('logo')->store('images','public');
它将图片存储在
storage/app/public/images/0HHJ5DygYUXuLC5dgu14KJTPvCEaxhISV8tpb4Pq.png
我使用Storage::delete('/images/0HHJ5DygYUXuLC5dgu14KJTPvCEaxhISV8tpb4Pq.png');
删除了它。但它不起作用;
我尝试过的是:
Storage::delete(asset('storage/images/0HHJ5DygYUXuLC5dgu14KJTPvCEaxhISV8tpb4Pq.png'));
Storage::delete(storage_path('images/0HHJ5DygYUXuLC5dgu14KJTPvCEaxhISV8tpb4Pq.png'));`
即使我尝试删除公用文件夹中的某些图片也是如此。它不起作用。
Storage::delete(public_path('images/logo3.png'));
我做错了吗?
答案 0 :(得分:5)
这对我有用,希望对您也有用:
|query(''' SELECT derivative(mean("bandwidth_in"), 1s) *8 as "value" FROM "router"."autogen"."cisco_router" where host = '10.1.11.1' and ( interface_name = 'XXX' or interface_name = 'XXXXX')) AND time < now() GROUP BY time(1s) ''')
.cluster('network')
.period(7m)
.every(6m)
.groupBy(time(10s), *)
答案 1 :(得分:0)
这是删除文件的php方法。 unlink()函数。
$file = $request->input('filename');
unlink(storage_path('app/public/images/' . $file));
答案 2 :(得分:0)
delete方法接受一个文件名从磁盘中删除:
Storage::delete('public/images/filename.png');