my.chooseFileFromDisk

You can choose a file to upload. You can also view the details of the file or delete the file you have added.

Supported types of mini programs: DSL, H5+

Sample code

DSL

copy
my.chooseFileFromDisk({
  success: res => {
    console.log(res);
  },
  fail: err => {
    console.log(err);
  }
});

H5+

copy
AlipayJSBridge.call('chooseFileFromDisk', {}, function (res) {
  alert('AlipayJSBridge chooseFileFromDisk result:\n' + JSON.stringify(res));
});

Parameters

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.

Success callback function

Property

Type

Description

apFilePath

string

The temporary local file path.

Failure callback function

Property

Type

Description

error

number

Error code.

errorMessage

string

Error message.

Error codes

Error code

Error message

Further action

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.

Failed to copy the file. Please try again or check the file permissions.

15

The user cancels the file selection.

The user cancels to select the file.

18

Choosing large file is not supported.

The selected file is too large; please choose a smaller file.

File size limit

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.