my.chooseImage

Choose an image from the camera or gallery of a device.

Supported types of mini programs: DSL, H5+

Sample Code

copy
my.chooseImage({
  success: (res) => {
    img.src = res.apFilePaths[0];
  },
});

Parameters

PropertyType

Required

Description
sourceTypeString ArrayNoCamera or album, [‘camera’,‘album’] by default.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

PropertyTypeDescription
apFilePathsString ArrayImage file description.

Error Code

Error code

Error message

Further action

2

Invalid param : sourceType = ${sourceType}

Refer to the previous Parameters table to ensure that all parameters are specified correctly, and that all required parameters are provided.

11

User canceled

User cancels this image choosing operation. No action required in this normal flow.

14

No camera access rights

Please enable the device camera access permissions.

15

No album access rights

Please enable the device gallery access permissions.