Skip to content

Instantly share code, notes, and snippets.

@ascorbic
Created February 5, 2011 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ascorbic/812387 to your computer and use it in GitHub Desktop.
Save ascorbic/812387 to your computer and use it in GitHub Desktop.
A full example, that should work.
var gotPicture = function(path) {
$('#previewPic').attr('src', path); /*optional */
var params = {foo: 'bar'};
var cookie = localStorage.getItem("Cookie");
if(cookie) {
params['__cookie'] = cookie;
}
window.plugins.fileUploader.uploadByUri('http://example.com/upload', path, params, 'photo', 'image.jpg', 'image/jpeg',
function(result) {
console.log('Done: ' + result);
},
function(result) {
console.log("error: " + result);
},
function(loaded, total) {
var percent = 100 / total * loaded;
console.log('uploaded ' + percent);
}
);
}
}
var getPhoto = function() {
navigator.camera.getPicture(gotPicture, null, {destinationType: Camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY} );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment