Book Image

Phonegap Essentials

By : Ivan Turkovic
Book Image

Phonegap Essentials

By: Ivan Turkovic

Overview of this book

Table of Contents (15 chapters)

File Transfer


The File Transfer plugin enables you to download uploaded files from your server. It is used together with media content capability to upload to your server without interrupting your main thread. File Transfer provides a way to upload HTTP multi-part POST requests.

To install the plugin, you need to run the following command:

phonegap plugin add cordova-plugin-file-transfer

The File Transfer plugin will make available two global objects—FileTransfer and FileUploadOptions—that will be available after the deviceready event has been fired. We are going to describe them in detail in the following paragraphs:

document.addEventListener("deviceready", function() {
   console.log(FileTransfer);
}, false);

Examples for this plugin need to have the server to communicate with. Since the scope of this book is limited to learning PhoneGap essentials, I am going to show you how it works with real code, however, since you do not have a running server, you cannot run this on your devices.

The...