The FileTransfer object lets you upload files to a remote server using an HTTP multi-part POST request. Both HTTP and HTTPS protocols are supported. You can also specify optional parameters with the FileUploadOptions object. When you successfully upload a file, the results are stored in a FileUploadResult object. All errors are stored in a FileTransferError object.

Following is an example:

function success(f) {
alert("Code = " + f.responseCode);
alert(" Response = " + f.response);
alert("Sent = " + f.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " = error.code);
}
var upload_options = new FileUploadOptions();
upload_options.fileKey = "file";
upload_options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
upload_options.mimeType = "text/plain";
var params = new Object();
params.value1 = "sample text";
params.value2 = "another sample";
upload_options.params = params;
var ft = new FileTransfer();
ft.upload(fileURI, "http://some.server.com/upload.php", success, fail, options);

FileUploadOptions

As mentioned,a FileUploadOption object can be passed to the FileTransfer objects upload method in order to specify additional parameters to upload script. We can pass along a set of options when you perform a file upload. These options are stored in a FileUploadOptions object.
The FileUploadOptions object has the following properties.

FileUploadResults

When you successfully upload a file, the results are stored in a FileUploadResult object.
The FileUploadResult object has the following properties.

FileTransferError

A FileTransferError object is returned via the error callback when an error occurs. It contains one property, code, which is one of the following predefined codes:

Supported Platform for Beep and Vibrations

Resources

Some of the useful resources are as follows.

Filesystem-Reading Files in PhonGap
Filesystem-Writing Files in PhonGap
FileSystem FileEntry Objects Using PhoneGap
FileSystem-DirectoryEntry Objects in PhoneGap