The official WeChat document provides methods for uploading files:
wx.chooseMessageFile(Object object)
The basic library 2.5.0 starts to support, and the lower version needs to be compatible .
Select the file from the client session.
Mainly by changing the value of type to select the type that needs to be uploaded, it needs to be tested on a real machine
The uploaded picture is as follows:
wx.chooseMessageFile({
count: 10,
type: 'image',
success (res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFiles
}
})
See the document for details: https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html