cfclient.file.upload

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.

Example

 See Getting Started Examples

//A function to capture and uplaod an image to a remote server
function uploadImageToServer(imageURI)
{
var uploadOptions = new FileUploadOptions();
uploadOptions.fileKey="uploadedImageFile";
uploadOptions.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
uploadOptions.mimeType="image/jpeg";

uploadOptions.chunkedMode = false;

var fileTransferObj = new FileTransfer();

fileTransferObj.upload(imageURI,
"http://<Your_Server>:8500/ImageReceiver/receiveImage.cfm",
function(){
alert("File uploaded to the server");
},
function (e){
alert("Error uploading file to the server");
}, uploadOptions);
}

Logo Adobe

Přihlaste se ke svému účtu.