ajax多图片上传

$('body').on('change', '#addformfile',function() {
var file = new FormData();
var fileslist=$(this)[0].files;
var l=fileslist.length;
for(var i=0;i<l;i++){
file.append("pic[]",$(this)[0].files[i]);
}
if(file){
$.ajax({
url:"__URL__/upload",
type:"post",
data:file,
async: false,
cache: false,
processData:false,
contentType:false,
success:function(ldata){
//数据处理
},
error:function(e){
console.log(JSON.stringify(ldata));
}
});
}
});

猜你喜欢

转载自www.cnblogs.com/fuxp/p/12336424.html