<form id= "uploadForm"> ajax
<p >指定文件名: <input type="text" name="filename" value= ""/></p > async
<p >上傳文件: <input type="file" name="file"/></ p> url
<input type="button" value="上傳" onclick="doUpload()" /> spa
</form> orm
function doUpload() { 接口
var formData = new FormData($( "#uploadForm" )[0]); input
$.ajax({ string
url: 'xxx' , --------------這裏是請求的接口io
type: 'POST', function
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
alert(returndata);
},
error: function (returndata) {
alert(returndata);
}
});
}