$('#update_products').on('submit',function(event){
event.preventDefault()
console.log(data)
$.ajax({
url:'/UpdateProduct',
type:'POST',
data:new FormData(this),
dataType:'JSON',
contentType: false,
cache: false,
processData: false,
success:function(data){
console.log(data)
}
})
})
<form enctype="multipart/form-data" id="update_products" method="post">
<div class="js--image-preview"></div>
<div class="upload-options">
<label class="upload-lbl" for="photo1">
</label>
</div>
</div>
<input type="file" class="product-image-upload" accept="image/*" name="images[]" id="photo1"/>
</form>
let $form = $('#update_products');
$form.on('submit', function (event) {
event.preventDefault();
let formData = new FormData($form[0]);
$.each($('.product-image-upload')[0].files, function (j, file) {
formData.append('images[' + j + ']', file);
});
$.ajax({
url: '/UpdateProduct',
type: 'post',
data: formData,
contentType: false,
cache: false,
processData: false,
success: function (data) {
console.log(data);
}
});
});
<input type="file" class="product-image-upload" accept="image/*" name="images[]" id="photo1" multiple>
if ($request->hasFile('images')) {
$files = $request->file('images');
}