<input type="file" id="img_file">
<button id="shangchuan" type="button">点击上传</button>
//上传图片的ajax
$("#shangchuan").click(function() {
console.log(222)
jQuery.ajaxFileUpload({
url: url + "appapi/fabu/uploadImage", //需要链接到服务器地址
type: 'POST',
secureuri: false,
fileElementId: "img_file", //文件选择框的id属性 ,//文件选择框的id属性
dataType: 'json', //json
data: {},
// contentType: false, //不可缺
// processData: false, //不可缺
success: function(data, status) {
console.log(data.data);
console.log(data);
console.log("666");
},
// error: function(XMLHttpRequest, textStatus, errorThrown) {
// alert("上传失败,请检查网络后重试");
// }
})
console.log(111)
})
报错

原因:<input type="file" id="img_file">没有添加
name="file"
解决后代码:
<input type="file" name="file" id="img_file">
<button id="shangchuan" type="button">点击上传</button>
