jQuery上传文件和API接收保存文件
- jQuery代码是:
<input type="file" id="files" name="files" multiple />
<input type="button" id="upload" value="Upload Selected Files" />
$("#upload").click(function (evt) {
var fileUpload = $("#files").get(0);
var files = fileUpload.files;
var data = new FormData();
console.log("length=" + files.length);
for (var i = 0; i < files.length ; i++) {
data.append(files[i].name, files[i]);
}
data.append("1111", "222");
$.ajax({
type: "POST",
url: "http://localhost:50090/api/test",
contentType:false,
dateType:"json",
processData: false,