my.chooseFileFromDisk allows users to select a file from their device storage. You can view the details of the file or delete the file you have added.
Supported types of mini programs: DSL, H5+
my.chooseFileFromDisk({
success: (res) => {
console.log(res);
},
fail: (err) => {
console.log(err);
},
});
AlipayJSBridge.call("chooseFileFromDisk", {}, function (res) {
alert("AlipayJSBridge chooseFileFromDisk result:\n" + JSON.stringify(res));
});
Object type with the following attributes:
| Property | Type | Required | Description |
|---|---|---|---|
success | Function | No | The callback function for a successful API call. |
fail | Function | No | The callback function for a failed API call. |
complete | Function | No | The callback function used when the API call is completed. This function is always executed no matter the call succeeds or fails. |
The incoming parameter is of the Object type with the following attributes:
| Property | Type | Description |
|---|---|---|
apFilePath | String | The temporary local file path. |
The incoming parameter is of the Object type with the following attributes:
| Property | Type | Description |
|---|---|---|
error | Number | Error code. |
errorMessage | String | Error message. |
| Error code | Error message | Remark |
|---|---|---|
4 | The JSAPI call is denied. | The mini program that is developed by the merchant/ISV has no right to call the JSAPI. |
12 | Errors occur when copying the file. | |
15 | The user cancels the file selection. | |
16 | The user denies the permission to read the storage. | Android Only. |
17 | No permission to read the storage. | Android Only. |
18 | Choosing large file is not supported. |
Note: The following list describes the difference between the error code 16 and 17:
If you choose a file that is too large, the mini program or the wallet app cannot run properly. For this reason, the file size is limited to 50 MB. When the file size exceeds 50 MB, the error code of 18 is returned, and the corresponding error message is displayed.
apFilePath)apFilePath with other file APIs like my.uploadFile or my.openDocument