收藏
回答

怎么上传多个图片呢 急

为什么上传就一个图片呢 不能上个多图片呢?


回答关注问题邀请回答
收藏

13 个回答

  • 厚光
    厚光
    2017-10-23

    @You can you up 官方API只有单个文件上传,并且最多并发10个

    2017-10-23
    有用
    回复
  • XinLin
    XinLin
    2017-10-23

    wxml是

     <image src="{{src}}"   controls ></image>

      <view class="btn-area">

        <button bindtap="bindButtonTap">上传图片</button>

      </view>

    </view>


    2017-10-23
    有用
    回复
  • You can you up
    You can you up
    2017-10-23

    @不忘初心@小糖糖

    能给我发下不  万分感激     谢谢了!!!


    2017-10-23
    有用
    回复
  • You can you up
    You can you up
    2017-10-23

    @厚光  我也想知道   二楼不是说知道么

    for循环 方法也是每次上传一次  多次上传而已  会有很多问题

    文件地址支持数组就好了

    2017-10-23
    有用
    回复
  • 小糖糖
    小糖糖
    2017-10-23

    upload:function(){

      var that=this

      wx.chooseImage({

        count: 9, 

        sizeType: ['original', 'compressed'], 

        sourceType: ['album', 'camera'], 

        success: function (res) {

          var tempFilePaths = res.tempFilePaths


          console.log(tempFilePaths)

          wx.uploadFile({

            url: 'file_upload.php', 

            filePath: tempFilePaths[0],

            name: 'file',

            formData:{

              'user': 'test'

            },

            success: function(res){

              var data = res.data

              wx.showModal({

                title: '上传文件返回状态',

                content: '成功',

                success: function(res) {

                  if (res.confirm) {

                    console.log('用户点击确定')

                  }

                }

              }) 

              const uploadTask = wx.uploadFile({

                url: 'file_upload.php', //仅为示例,非真实的接口地址

                filePath: tempFilePaths[0],

                name: 'files',

                formData:{

                  'user': 'test'

                },

                success: function(res){

                  var data = res.data

                    //do something

                  }

                })


              uploadTask.onProgressUpdate((res) => {

                that.setData({

                  progress:res.progress

                })


                console.log('上传进度', res.progress)

                console.log('已经上传的数据长度', res.totalBytesSent)

                console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)

              })


            uploadTask.abort() // 取消上传任务                         

          },

          fail:function(res){

            console.log(res)

          }

        }),



          that.setData({

            path:tempFilePaths

          })  

        }

      })

    },


    2017-10-23
    有用
    回复
  • 厚光
    厚光
    2017-10-23

    @You can you up 你有更好的办法可以分享下.

    2017-10-23
    有用
    回复
  • PENll
    PENll
    2017-10-23

    不就是,chooseImage多个图片后,保存返回的多个图片地址。后面自己做批量上传

    2017-10-23
    有用
    回复
  • You can you up
    You can you up
    2017-10-23

    这for循环还是拉倒吧

    2017-10-23
    有用
    回复
  • 厚光
    厚光
    2017-10-23
    wx.chooseImage({
                            success: function (res) {
                                for (let index in res.tempFilePaths) {
                                    that.uploadFile(res.tempFilePaths[index]).then(function (resolve) {
                                        let thumbPath = that.data.thumbPath;
                                        let thumb = that.data.thumb;
                                        thumbPath.push(resolve);
                                        thumb.push(app.baseUrl + resolve);
                                        that.setData({
                                            thumbPath: thumbPath,
                                            thumb: thumb
                                        });
                                    }, function (reject) {
                                        console.log(reject);
                                    })
                                }
                                wx.hideLoading();
                            }
                        })


    2017-10-23
    有用
    回复
  • XinLin
    XinLin
    2017-10-23

    @不忘初心  怎么做

    2017-10-23
    有用
    回复

正在加载...

登录 后发表内容