Micro-Letter Applet Wx.uploadfile on the Android phone the same task is working problem resolution
Micro-Letter Small program upload pictures, if it is more than image upload, generally is directly with a loop for wx.uploadfile
It's not going to be a problem on the computer and on the iphone.
But when you use the Android test, you'll notice that the applet prompts a same task is working
Wx.uploadfile can't be parallel because Wx.uploadfile is an asynchronous function, so there's a parallel on the Android phone at the time of the loop.
Way to solve
Do an uploaded logo, and then
Using recursive algorithm to upload
In the upload of successful callback function, direct recursion, logo satisfied directly jump out, complete all picture upload
Post Code Snippet
Upload ID var i=0//imglist for an array of paths to upload images uploadimg:function () {var that =-this if (i = = imglist.length) {//empty restore
News = "" City = "" i=0 wait = True imglist = [] serverimg = [] Retrunlist = [] That.setdata ({
Loding:false, SRC: [], disabled:false}) return;
var imgcount = imglist.length; Wx.uploadfile ({url:config.serverUrl (' index.php/user/uploadtu '), Filepath:imglist[i], name: ' File ', form Data: {' user ': ' Test '}, Success:function (res) {Serverimg.push (Res.data) if (Imgcount = = Serverimg.lengt
h) {var serverimgstr = Serverimg.join ("|") Wx.request ({url:config.serverUrl (' Index.php/user/baobeiadd '), method: ' POST ', Data:Util.json2Form ( {imglist:serverimgstr, Userid:userid, News:news, city:city, Latitude:latitud E, longitude:longitude}), header: {' Content-type ': ' Application/x-www-forM-urlencoded '}, Success:function (Res2) {if (res2.data.state = = "OK") {That.setdata ({ Loding:false, Buttxt: "Publish", Disabled:false}) Util.mesurl ("Send Cloth Success! ", ".. /index/index ")} else {util.mes (" description of at least 10 characters above oh, and pictures also to choose Oh! ")
")}})}else {//here directly recursively i++;
That.uploadimg (); }, Fail:function (e) {Console.log (E) util.mes ("Picture upload failed, please republish!")
"+ i)}}"},
Thank you for reading, I hope to help you, thank you for your support for this site!