Capture image and upload to server using PhoneGap

Md. Ziyed Uddin

Client Side Script

PhoneGap Capture Image API: Capture Image PhoneGap API

 //Camera Section // Wait for PhoneGap to load document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap is ready function onDeviceReady() {} // Called when capture operation is finished // function captureSuccess(mediaFiles) { uploadFile(mediaFiles[0]); } // Called if something bad happens. // function captureError(error) { var msg = 'An error occurred during capture: ' + error.code; navigator.notification.alert(msg, null, 'Uh oh!'); } // A button will call this function // function captureImage() { // Launch device camera application, // allowing user to capture only one image by {limit: 1} navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 1 }); } // Upload files to server function uploadFile(mediaFile) { path = mediaFile.fullPath; name =; var options = new FileUploadOptions(); options.fileKey="file";; options.mimeType="image/jpeg"; var params = new Object(); params.fullpath = path; = name; options.params = params; options.chunkedMode = false; var ft = new FileTransfer(); ft.upload( path, "", function(result)…

View original post 28 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s