When WeChat Mini Program uploads files, you can only select pictures or videos from the photo album. You cannot select files in the phone's memory card, such as word, pdf files, etc.
The above functions can be achieved through webview and h5:
#Add business domain name
The address opened in webview first needs to be added to the business domain name of the mini program background, otherwise it will not be opened:
https://ns.s2m.cc
Please add the above domain name to your business domain name
# Add webview page to mini program
```xml```
```javascript
Page({
data: {
},
onLoad: function (options) {
this.setData({
src: 'https://ns.s2m.cc/upload?domain=tz&maxCount=2'
})
},
})
```
+ domain Pass your own exclusive domain name
+ maxCount file upload limit
# How to use
Where you need to initiate file upload, jump to the webview interface above:
```javascript
wx.navigateTo({
url: 'webview path',
})
```
After the upload is completed, the webview will return to the original page. You can read the URL address of the uploaded file through the following method:
```javascript
WXAPI.channelDataPull('uploadH5Url')
```
Will return an array of files uploaded this time