File delete not actually deleting a file

Posted 2 years ago by AlexanderKim

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

Please sign in or create an account to participate in this conversation.