$('.file').change(function(){ var formData = new FormData(); for(x in $(this)[0].files){ formData.append("file", $(this)[0].files[x]); } $.ajax({ url : "/upload/uploadFile.do", type : "post", cache: false, data: formData, dataType:"json", processData: false, contentType: false, success: function(result){ if(result.code == "1" && result.data){ //bootbox.alert("文件上传成功!"); $('.uploadImageSuccess').show().attr('src',imgPath+'/'+result.data[0]) $('[name=infoImgUrl]').val(result.data[0]); } else { bootbox.alert(result.msg); } }}); }); });