have everything set up for uploading images with Laravel except this issue.
I have made a class to handle all the image uploading, and then I have this ajax code:
$(document).on('submit', ".header-image-form", function(e){
e.preventDefault();
$.ajax({
url:'/feature/uploadImage',
data: new FormData(this),
headers: {
'X-CSRF-Token': $('form.header-image-form [name="_token"]').val()
},
async:false,
type:'post',
processData: false,
contentType: false,
success:function(response){
console.log(response);
},
});
});
This is my form:
<form class="header-image-form" enctype="multipart/form-data">
{!! csrf_field() !!}
<input type="text" name="name" value="qwffwq">
<input type="file" name="image" id="header-image-input">
</form>
And then my route:
Route::post('/feature/uploadImage', [
'middleware' => 'isPublisher',
'uses' => 'FeatureController@uploadImage'
]);
In my controller I am just returning back the request data and it returns the test field I put in the form but its returning an empty object for my image.
Where am I going wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire