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

NameTypeMandatoryDescription
urlStringYesAddress of the developer server
filePathStringYesLocal locator of the file resource   to be uploaded
fileNameStringYesFilename, also the corresponding   key. The developer uses this key at the server side to get the file binary   contents.
fileTypeStringYesFile type, image / video / audio
headerObjectNoHTTP request Header
formDataObjectNoOther additional form data in the   HTTP request
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:

NameTypeDescription
dataStringData returned from the server
statusCodeStringHTTP status code
headerObjectHeader returned from the server

Error Code

errorDescription
11File nonexistent
12File uploading failed
13No right