【发布时间】:2017-09-06 14:53:49
【问题描述】:
当尝试删除图像时,我需要将其从磁盘中完全删除
功能:
public function setUrlAttribute($value)
{
$attribute_name = "url";
$disk = "public";
$destination_path = "uploads/equipos";
if ($value==null) {
// delete the image from disk
Storage::disk($disk)->delete($this->url); //<---- fix here
// set null in the database column
$this->attributes[$attribute_name] = null;
}
删除映像时,没有任何变化,需要帮助从磁盘物理删除映像。
【问题讨论】:
-
你是使用
->delete()函数还是手动设置url为null? -
我正在使用删除来物理删除图像
-
我对另一种类型的文件 pdf 有相同的方法,奇怪的是它可以删除文件并在数据库上设置 null。
-
\Storage::disk()->delete('uploads/equipos'.$this->url);试过这个没有成功