my.uploadFile
Upload the local resource to the server.
Sample Code
my.uploadFile({
url: 'Please use your own server address',
fileType: 'image',
fileName: 'file',
filePath: '...',
success: (res) => {
my.alert({
content: 'Upload success'
});
},
});
Parameters
Property | Type | Required | Description |
url | String | Yes | Address of the developer server. |
filePath | String | Yes | Local locator of the file resource to be uploaded. |
fileName | String | Yes | Filename, also the corresponding key. The developer uses this key at the server side to get the file binary contents. |
fileType | String | Yes | The file type of the uploaded file. Note: This parameter is only used for backward compatibility with older super app versions. If you have previously set a value for this parameter, no changes are necessary. If not, you can set the value to |
header | Object | No | The HTTP request header. You can specify this parameter using any common headers. Note: By default, the Content-Type request header is set to |
formData | Object | No | Other additional form data in the HTTP request. |
timeout | Number | No | The timeout period of your request in milliseconds. The default value is |
hideLoading | Boolean | No | Whether to hide a loading icon during the uploading process. Valid values are:
If not specified, the value defaults to |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback 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:
Property | Type | Description |
data | String | Data returned from the server. |
statusCode | String | HTTP status code. |
header | Object | Header returned from the server. |
Error Code
Error | Description |
11 | File nonexistent. |
12 | File uploading failed. |
13 | No right. |