Skip to content

Instantly share code, notes, and snippets.

@melaniehoff
Created July 20, 2016 15:51
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 melaniehoff/975ca4cfa17e4877a30334dcdbca97e4 to your computer and use it in GitHub Desktop.
Save melaniehoff/975ca4cfa17e4877a30334dcdbca97e4 to your computer and use it in GitHub Desktop.
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