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.
In this recipe, we will build an application that allows the user to take a photograph and upload it on a remote server:
Firstly, create a new PhoneGap project named
upload
by running the following line:phonegap create upload com.myapp.upload upload
Add the devices platform. You can choose to use Android, iOS, or both:
cordova platform add ios cordova platform add android
Add the
file
,camera
, andfile-transfer
plugins by running these lines of code:phonegap plugin add org.apache.cordova.file phonegap plugin add org.apache.cordova.camera phonegap plugin add org.apache.cordova.file-transfer
We're going to use the
XUI
JavaScript library to easily access the DOM elements, so we'll include the reference to the file within thehead
tag.Open
www/index.html
....