public
Last active

ghetto-photoshare app logic

  • Download Gist
index.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<!DOCTYPE html>
<html>
<body>
 
<script src="phonegap-1.0.0.js"></script>
<script>
function uploadPhoto(imageURI) {
function win(r) {
alert('Image uploaded successfully!')
}
 
function fail(err) {
alert("Ruh roh. Image failed to upload! Errorcode: " = err.code)
}
 
var opts = new FileUploadOptions();
opts.fileKey = "file";
opts.fileName = imageURI.substr(imageURI.lastIndexOf('/')+1);
opts.mimeType = "image/jpeg";
opts.params = {};
 
var ft = new FileTransfer();
ft.upload(imageURI, "http://deep-flower-8321.herokuapp.com", win, fail, opts);
}
 
 
function win(photo) {
uploadPhoto(photo)
}
 
function fail(err) {
navigator.notification.alert('Uh oh!')
}
 
function snap() {
var opts = {
targetWidth: 300,
targetHeight: 300,
destinationType : Camera.DestinationType.FILE_URI
}
navigator.camera.getPicture(win, fail, opts)
}
</script>
<button onclick="snap()" style="font-size:2em; margin:0 auto 0 auto;">Capture Image</button>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.