I have a form that requires a user to upload 2 files, file-upload & imgupload. I am trying to save the entire form through ajax.
Try this one
JS Code
$("#save").click(function()
{
var formData = new FormData();
$f1 = $('#file-upload');
$f2 = $('#imgupload');
formData.append('file-upload', $f1.get(0).files[0]);
formData.append('imgupload', $f2.get(0).files[0]);
jQuery.ajax(
{
type: "POST",
url: "" + "comp/wfc",
data: formData,
processData: false,
contentType: false,
success: function(res)
{
console.log(res);
alert(res);
}
});
});
FYI, You can try below too if you are not aware of
Instead of multiple file input try to the single file input with multiple = "multiple"