小程序图片上传

 uploadimg:function(){
    var that = this;
    wx.chooseImage({ //从本地相册选择图片或使用相机拍照
     count: 1, // 默认9
     sizeType: [‘original‘, ‘compressed‘], // 可以指定是原图还是压缩图,默认二者都有
     sourceType: [‘album‘, ‘camera‘], // 可以指定来源是相册还是相机,默认二者都有
     success:function(res){
     //console.log(res)
     //前台显示
     that.setData({
      source: res.tempFilePaths
     })
     // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
     var tempFilePaths = res.tempFilePaths
      wx.uploadFile({
      url: ‘http://qicun.rdmate.com/qicun/wc_mini_program.common/uploadFile‘,//接口地址
      filePath: tempFilePaths[0],//图片路径
      name: ‘images‘,//请求参数
      success:function(res){
      //打印
      console.log(res.data)
      }
     })
     }
    })
    },

小程序图片上传

原文:https://www.cnblogs.com/sjruxe/p/14692746.html

以上是小程序图片上传的全部内容。
THE END
分享
二维码
)">
< <上一篇
下一篇>>