$('#form').on('submit', function (e) {
var file = $('input[type=file]')[0].files[0],
data = new FormData($(this)[0]);
if (file == null) {
alert("File is empty");
return false;
}
e.preventDefault();
submit(data);
});
function submit(data) {
$.ajax({
...
data: data,
method: "POST",
contentType: false,
processData: false,
...
});
}