Upload a file

You can upload a file to  a remote server using an HTTP multi-part POST request.

Method summary

cfclient.file.upload(fileName,url,successCallback, errorCallback,[options])

  • returns - None
  • params
    • fileName – Absolute or relative path of a file name (including file name)
    • url - The remote server URL
    • successCallback - The function to be invoked upon success/completion
    • errorCallback - The function to be invoked if there is a file transfer error

Options object

 The following options are also supported:

-trustAllHosts - Defaults to false. If set to true, it accepts all the security certificates. This is useful because Android rejects self-signed certificates. It is not recommended to set this as true for production use.


 See Getting Started Examples

//A function to capture and uplaod an image to a remote server
function uploadImageToServer(imageURI)
var uploadOptions = new FileUploadOptions();

uploadOptions.chunkedMode = false;

var fileTransferObj = new FileTransfer();

alert("File uploaded to the server");
function (e){
alert("Error uploading file to the server");
}, uploadOptions);


Get help faster and easier

New user?