Precautions

The applet does not support uploading non-image video files

H5 and APP

Use uni.chooseFile(OBJECT)

Select file from local

Mainly used to select non-media files. If the selected file is a media file, there are 3 dedicated APIs:

  • Picture selection: uni.chooseImage(OBJECT)
  • Video selection: uni.chooseVideo(OBJECT)
    *Multimedia file selection: uni.chooseMedia(OBJECT)

uni.chooseFile({
  count: 6, //default 100
  Extension: ['.zip','.doc'],
    Success: features (resources) {
        console.log(JSON.stringify(res.tempFilePaths));
    }
});

// Select picture file
uni.chooseFile({
  Number: 10,
  Type:'Image',
  Success (resource){
    // tempFilePath can be used as the src attribute of the img tag to display pictures
    const tempFilePaths = res.tempFiles
  }
})
``

### OBJECT parameter description

![image.png](https://cdn.elephdev.com/uploads/20210920/1605dff3db9cea1d3f52e0c378745fd0.png)

* Calculate the performance value of the H5 platform, based on the specifications made by the browser. According to the current test results, only single selection/multiple can be restricted, not the number. Moreover, there is no option in a particular mobile phone browser that can support multiple selections.
* The sourceType corresponds to the input capture attribute at the H5 end. It is invalid to set it to ['album'], and the camera can still be used.
* Extension temporarily only supports file extensions, such as ['.zip','.exe','.js'], and does not support similar values ​​such as application/msword

### Legal value of OBJECT.type

![image.png](https://cdn.elephdev.com/uploads/20210920/20ba0e92fd23a253f0a578ac234fb158.png)

* If the type attribute and extension exist at the same time, for example {type:'image',extension:['.png','.jpg']}, select image/png, image/jpg file as subject
* If you only configure extended attributes, such as {extension:['.doc','.xlsx','.docx']}, scientifically select .doc, .xlsx, .docx files, see accept attribute for details
* In the WeChat environment, if type="all", the extended attribute is invalid

###Successful return parameter description

![image.png](https://cdn.elephdev.com/uploads/20210920/96d1328f861ee0bf289eb52d0ba10a4b.png)

###File object structure is as follows

![image.png](https://cdn.elephdev.com/uploads/20210920/5169946b1a1fc5c313e257be3ec187a5.png)
Likes(0)

Comment list count 0 Comments

No Comments

WeChat Self-Service

WeChat Consult

TaoBao

support@elephdev.com

发表
评论
Go
Top