Created
July 20, 2016 15:51
-
-
Save melaniehoff/975ca4cfa17e4877a30334dcdbca97e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imageData = canv.elt.toDataURL(); | |
var blobBin = atob(imageData.split(',')[1]); | |
var array = []; | |
for (var i = 0; i < blobBin.length; i++) { | |
array.push(blobBin.charCodeAt(i)); | |
} | |
var imageFile = new Blob([new Uint8Array(array)], { | |
type: 'image/png' | |
}); | |
var formData = new FormData(); | |
formData.append('userPhoto', imageFile); | |
$.ajax({ | |
url: "https://doppel.camera/api/photo", | |
type: "POST", | |
data: formData, | |
processData: false, | |
contentType: false, | |
enctype: 'multipart/form-data', | |
success: function(data) { | |
console.log(data); | |
gotNewImage(data, 0); | |
}, | |
error: startOver | |
}); | |
imageData = canv.elt.toDataURL(); | |
var blobBin = atob(imageData.split(',')[1]); | |
var array = []; | |
for (var i = 0; i < blobBin.length; i++) { | |
array.push(blobBin.charCodeAt(i)); | |
} | |
var imageFile = new Blob([new Uint8Array(array)], { | |
type: 'image/png' | |
}); | |
var formData = new FormData(); | |
formData.append('userPhoto', imageFile); | |
function gotNewImage(images, indexToTry) { | |
loadImage(images[indexToTry], showNewImage, function(){ | |
if (indexToTry < images.length - 1) { | |
gotNewImage(images, indexToTry + 1); | |
} else { | |
imageLoaded = true; | |
console.log('HEY BABY ;)'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment