Im getting a empty file response when sending the formData in ajax, It has a fileupload and some input fields. I get the response in input fields but in file upload its empty. See picture below for code.
<div class="form-group">
<label for="attachments" class="control-label col-xs-1" style="padding: 0px 0px;">Add attachments</label>
<div class="col-lg-8">
<input type="file" name="attachments[]" id="attachments" class="custom-file-input" accept="application/pdf" multiple>
</div>
<div class="col-lg-8">
<input type="text" name="name_file" id="name_file">
</div>
$("#acpl_submit").on("submit", function() {
var formData = new FormData(this);
formData.append("test", "test");
$.ajax({
type: 'POST',
// enctype: 'multipart/form-data',
url: URL,
data: formData,
processData: false,
contentType: false,
cache: false,
success: function (data) {
console.log(data);
},
error: function (data)
{
console.log('Error:', data);
}
});
return false;
});
PHP file, returning the POST data for checking.
public function save_accomp() {
return response()->json(request()->all());
}