Level 2
Try using Storage::delete()
$path = '/images/pages/'. $img;
Storage::delete($path);
Hi Friends,
I am trying to delete a uploaded image file from path in laravel 5.4. But when I trying to delete it I have got following error.
"unlink(E:\xampp\htdocs\project-path\public/images/pages/): Permission denied"
My controller like this
public function destroy(Request $request, $id)
{
$id = decode($id);
$img = $request->imgValue;
$Path = public_path().'/images/pages/'.$img;
// fclose($Path);
if(file_exists($Path)){
unlink($Path);
}
if($request->ajax()){
if(\App\Image::destroy($id)){
return response()->json(array(
'success' => true
));
}
}else{
return redirect()->action('UsersController@index');
}
}
Any one know solution for this error what I got above?
Please or to participate in this conversation.