I'm trying to upload an image via ajax. Javascript is returning "success", but my browser says there is a problem with upload. What am I doing wrong ?
<form action="" id="form-new-badge" method="POST" enctype="multipart/form-data">
<input id="new-file-path-static-image" required="required" class="file-path validate" type="file">
</form>
$("#new-file-path-static-image").on("change", function(){
alert("time to upload");
var formData = new FormData($(this)[0]);
alert(formData);
$.ajax({
url: apiUrl + "image/upload",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
xhrFields: {
withCredentials: true
},
success: function(data) {
alert("success " + data)
}
});
});
code : 310 description : "There is a problem with the upload."