国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

微信小程序如何實(shí)現ES6Promise.all批量上傳文件

發(fā)布時(shí)間:2021-07-06 14:08 來(lái)源:億速云 閱讀:0 作者:小新 欄目: web開(kāi)發(fā)

這篇文章主要介紹微信小程序如何實(shí)現ES6Promise.all批量上傳文件,文中介紹的非常詳細,具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

微信小程序 ES6Promise.all批量上傳文件實(shí)現代碼

客戶(hù)端

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ù)端

<?php
use IlluminateHttpRequest;
Route::post('/upload', function (Request $request) {
  if ($request->photo->isValid()) {
    $request->photo->storeAs('images/foo/bar/baz', $request->filename . '.' . $request->photo->extension());
    return ['success' => true, 'index' => $request->index];
  }
});

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系站長(cháng)郵箱:ts@56dr.com進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。

高清欧美性猛交XXXX黑人猛交| 玩弄JAPAN白嫩少妇HD小说| 日韩网红少妇无码视频香港| 欧洲无码一区二区三区在线观看| 女同性另类一区二区三区视频| 内射人妻无码色AV麻豆去百度搜|