我试图通过ajax上传图片。 Javascript正在返回"成功",但我的浏览器说上传存在问题。我做错了什么?
<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)
}
});
});
代码 : 310 描述 : &#34;上传存在问题。&#34;