大家好,我正在嘗試使用此功能從本地存盤中洗掉影像,但它回傳
在字串上呼叫成員函式 delete()
這是對的,因為當我使用dd(destination);它時,結果是:
public/imagen/1634302328.jpg
有沒有辦法將該字串轉換為路由路徑或其他解決方案以從存盤中洗掉影像?謝謝
這是我的功能:
public function destroy($id)
{
$autoridad = Autoridad::find($id);
$destination = 'public/imagen/'.$autoridad->imagen;
if(File::exists($destination)){
File::delete($destination);
}
$destination->delete();
return redirect()->route('autoridades.index');
}
}
uj5u.com熱心網友回復:
我想你的意思是$autoridad->delete()而不是$destination->delete(). 您分配$destination給影像的字串位置。這就是為什么它不允許你呼叫delete()它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/317413.html
