I would like to send an image with jquery ajax method to my server where laravel is installed but get a 405 Method not allowed error.
I also tried to create an "any" root, but still won't work. Also with all other posts on this topic I couldn't solve my problem.
So here is my javascript code.
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var data = new FormData();
data.append('file', resp);
$.ajax({
url: '/images/store',
type: 'POST',
data: data,
cache: false,
processData: false,
contentType: false,
success: function (data, textStatus, jqXHR) {}
});
on the Server side i use the Resource controller of laravel so this is the snippet from my routing file.
Route::resource('images', 'ImageController');
I think the store method of laravel is a post route, but as mentioned above also with an any route I get the 405 error.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire