<input type="file" class="add-view-img-btn j-upbtn" name="quanjing" data-type="quanjing" data-maxupimg="15" accept="image/jpeg">
$(".j-upbtn").on("change",function(e){
var _file = this.files[0];
var para = {};
para.name = $(this).attr("name");
para.type = $(this).attr("data-type");
para.maxupimg = $(this).attr("data-maxupimg");
var formData = new FormData();
formData.append("name", para.name);
formData.append("file", _file);
formData.append("type", para.type);
formData.append("data", $("-sharpdataParms").val());
formData.append("iscamera",2);
$.ajax({
url: "{:U("Api/Carclaim/uploadImage",array("sessionid"=>$_GET["sessionid"],"token"=>$_GET["token"]))}",
type: "POST",
data: formData,
processData: false,
contentType: false,
beforeSend:function(){
dialog.loading.open("");
},
complete:function(){
dialog.loading.close();
},
success: function (res) {
console.log(res)
if(res.status){
dialog.toast(res.msg,"success",2000);
var tmphtml = "<li id="file-"+res["data"]["id"]+"" class="view-img-item" onclick="openView(this)">"+
"<div class="bgimg" style="background-image:url("+res["data"]["imgPath"]+")"></div>"+
"<input type="hidden" name=""+res["data"]["type"]+"[]" value=""+res["data"]["id"]+""/>"+
"<span class="delspanCar" onclick="delspanCar("+res["data"]["id"]+",this)"><i class="iconfont icon-shanchu"></i></span>"+
"</li>";
$(obj).parents(".add-view-img-btn-wrap").siblings("ul").append(tmphtml)
}else{
dialog.toast(res.msg,"error",1500)
}
},
error:function(xhr,text){
dialog.toast(xhr, "error", 2000);
}
});
});
there is no problem with the above code in Wechat and mobile browsers. Put it in the embedded page, and the back end says that it cannot receive parameters. The parameters that are always returned are incomplete.
previously used the localResizeIMG plug-in to do compression,. There"s nothing wrong with it.
now I upload it to new formData instead. But it is still said that the parameters are not complete, it is really impossible to ask the great god for guidance!