Do you have the set the right permissions on the map where the files are being stored? https://laracasts.com/discuss/channels/general-discussion/laravel-framework-file-permission-security
Nov 17, 2016
15
Level 3
File delete not actually deleting a file
I am trying to delete a file via Ajax post request:
public function ajaxDeleteImage(Request $request) {
if ($request->ajax()) {
$path = $request->input('imgUrl');
$id = $request->input('id');
$currency = Currency::findOrFail($id);
$currency->cur_icon = '';
\File::delete($path);
$currency->save();
return 'Deleted image!';
}
return \App::abort(404);
}
However file is not being delete, but path to the image are deleted successfully. What might the problem? Laravel 5.2
Level 15
Then you would need:
\File::delete(public_path($path));
Forgot about the public_path() helper. At any rate, you need to use the absolute path.
2 likes
Please or to participate in this conversation.