with this?
$file = $request->file('file');
return response()->json($file->getRealPath());
to check if that file exists. you can dd and check what request contains inside controller
dd($request)
Here's ajax:
$.upload = function(file) {
let out = new FormData();
out.append('file', file, file.name);
$.ajax({
method: 'POST',
url: '/summer-uploads',
//check laravel document: https://laravel.com/docs/5.6/csrf#csrf-x-csrf-token
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
contentType: false,
cache: false,
processData: false,
dataType: 'JSON',
data: out,
success: function(url) {
console.log(url);
$('#description').summernote('insertImage', url);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error(textStatus + " " + errorThrown);
}
});
};
Controller:
public function summerUploads(Request $request)
{
if ($request->ajax()) {
$file = $request->input('file');
return response()->json($file->path());
}
return App::abort(404);
}
But i'm keep getting an error: "Call to a member function path() on null"
I guess, it's not getting the values from ajax's data? Because $file is null.
Please or to participate in this conversation.