zoukankan      html  css  js  c++  java
  • 小程序图片上传

     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)
          }
         })
          
         }
        })
        },
    正道的光终将来临,当太阳升起的时候,光芒总会普照大地温暖人间。些许的阴霾也终会有被阳光洒满的一天
  • 相关阅读:
    python判断语句和循环语句
    Web项目如何做单元测试
    PHP接口自动化测试框架实现
    引入缺陷的原因都有哪些?
    测试基础:(一)
    测试基础(二)
    测试术语2
    测试术语3
    测试术语4
    Spring Cloud Stream与Spring Cloud Bus区别?
  • 原文地址:https://www.cnblogs.com/sjruxe/p/14692746.html
Copyright © 2011-2022 走看看