步骤一、
var opts={
url: "这里是你的url",
type: 'post',
secureuri: false, //一般设置为false
fileElementId: 'imgFile', // 上传文件的id、name属性名
dataType: 'json', //返回值类型,一般设置为json、application/json
elementIds: {}, //传递参数到服务器
success: function(data, status){
//这里填写你的 处理函数
//create_image(data);
$("#imgFile").data("something",Math.random();
},
error: function(data, status, e){
alert("出错了");
$("#loading").hide();
}
}
function onchangeit(){
$.ajaxFileUpload(opts);
}
步骤二
<input type="file" accept="image/jpg,image/jpeg,image/png,image/gif" id="imgFile" data-something="8989898" name="imgFile" onchange="onchangeit()" />
如此即可
微信应用开发qq群 149031667