微信小程序文件上傳


 

操作:從本地相冊選擇圖片或使用相機拍照

API:wx.chooseImage(Object object)

wx.chooseImage({
  count: 1,
  sizeType: ['original', 'compressed'],
  sourceType: ['album', 'camera'],
  success (res) {
    // tempFilePath可以作為img標簽的src屬性顯示圖片
    const tempFilePaths = res.tempFilePaths
  }
})

 

 

 操作:從客戶端會話選擇文件

API: wx.chooseMessageFile(Object object)

wx.chooseMessageFile({
  count: 9, //最多上傳9張圖片
  type: 'image',
  success (res) {
    // tempFilePath可以作為img標簽的src屬性顯示圖片
    const tempFilePaths = res.tempFiles
  }
})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM