[Q] I am using laravel and while deleting a file in laravel It got error while code is live but worked fine in localhost.
Error Looked like this
controller is as follow
public function destroy($id)
{
$del=Slider::find($id);
if (!empty($del->image)) {
$image_path = public_path("images/slider/{$del->image}");
//File::delete($image_path);
unlink($image_path);
}
$chk=$del->delete();
if($chk){
$data=Slider::get();
Session()->flash('msg','A Slider has been deleted.');
return view('backend.slider',compact('data'));
}
}
[SOLUTION]
Instead of using unlik() I used File::delete()
so
unlink($image_path);
above code I replaced with
File::delete($image_path);
And Dont forget to add this to the top of the controller
use Illuminate\Support\Facades\File;
STRUCTURE (Submit after Mid Term , 15 Ashad 2083) A) MCQ 1. What is the…
FUNCTION (Assignment) Submit Before Mid Term MCQ 1. What is the output of this statement…
Evolution History of computer Technology (HISTORY OF COMPUTER) Evolution of computer is a study of…
Unit3_ClassMethodDesign_OOAD DOWNLOAD
Maturity of Enterprise Architecture Practice Maturity of Enterprise Architecture Practice DOWNLOAD
Report-on-final-project_Sample_2