O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Uploading a file on a remote server

Sometimes, working with only the local system for mobile applications is not enough. There are use cases for the requirement to interact with a remote server, for example, to share a file.

How to do it...

In this recipe, we will build an application that allows the user to take a photograph and upload it on a remote server:

  1. Firstly, create a new PhoneGap project named upload by running the following line:
    phonegap create upload com.myapp.upload upload
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:
    cordova platform add ios
    cordova platform add android
    
  3. Add the file, camera, and file-transfer plugins by running these lines of code:
    phonegap plugin add org.apache.cordova.file
    phonegap plugin ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required