新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
微信小程序如何實(shí)現(xiàn)ES6Promise.all批量上傳文件
這篇文章主要介紹微信小程序如何實(shí)現(xiàn)ES6Promise.all批量上傳文件,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)公司是網(wǎng)站建設(shè)技術(shù)企業(yè),為成都企業(yè)提供專業(yè)的成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè),網(wǎng)站設(shè)計(jì),網(wǎng)站制作,網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制適合企業(yè)的網(wǎng)站。10多年品質(zhì),值得信賴!
微信小程序 ES6Promise.all批量上傳文件實(shí)現(xiàn)代碼
客戶端
Page({ onLoad: function() { wx.chooseImage({ count: 9, success: function({ tempFilePaths }) { var promise = Promise.all(tempFilePaths.map((tempFilePath, index) => { return new Promise(function(resolve, reject) { wx.uploadFile({ url: 'https://www.mengmeitong.com/upload', filePath: tempFilePath, name: 'photo', formData: { filename: 'foo-' + index, index: index }, success: function(res) { resolve(res.data); }, fail: function(err) { reject(new Error('failed to upload file')); } }); }); })); promise.then(function(results) { console.log(results); }).catch(function(err) { console.log(err); }); } }); } });
服務(wù)端
photo->isValid()) { $request->photo->storeAs('images/foo/bar/baz', $request->filename . '.' . $request->photo->extension()); return ['success' => true, 'index' => $request->index]; } });
以上是“微信小程序如何實(shí)現(xiàn)ES6Promise.all批量上傳文件”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
名稱欄目:微信小程序如何實(shí)現(xiàn)ES6Promise.all批量上傳文件
URL標(biāo)題:http://fisionsoft.com.cn/article/ihiice.html