最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2017年04月14日 15:13:45   作者:馬小云  
這篇文章主要介紹了微信小程序 ES6Promise.all批量上傳文件實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下

微信小程序 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ù)端

<?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];
  }
});

 感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論

安庆市| 河南省| 张家口市| 西昌市| 无棣县| 连城县| 贵德县| 商丘市| 龙游县| 闽侯县| 尉犁县| 长治县| 安平县| 额敏县| 灵台县| 永兴县| 龙口市| 梓潼县| 施秉县| 新密市| 巫山县| 邢台市| 保山市| 万年县| 巴东县| 长葛市| 东乡族自治县| 舒城县| 石楼县| 盐源县| 高青县| 清水河县| 龙口市| 新民市| 浑源县| 临湘市| 张家川| 临朐县| 那曲县| 蒲城县| 通山县|