my.uploadFile
Upload the local resource to the server.
Sample Code
copy
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 | File type. The following file types are supported:
|
header | Object | No | HTTP request Header. |
formData | Object | No | Other additional form data in the HTTP request. |
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:
Name | 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 |