Last active
February 2, 2016 02:27
-
-
Save tahoeRobbo/a61a5427c472c501f0c2 to your computer and use it in GitHub Desktop.
Revisions
-
tahoeRobbo revised this gist
Jun 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ var uploadFile = function() { //RUNS AFTER THE READER.READAS...(FILE) IN THE IF STATEMENT. DELIVERS RESULTS AFTER EVERYTHING IS LOADED //SIMILAR TO PROMISE RESOLUTION reader.onloadend = function() { var imgRef = new Firebase('https://YOUR_APP.firebaseio.com/photos'); imgRef.push({ data : reader.result, caption : inputCaption, -
tahoeRobbo renamed this gist
Jun 22, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tahoeRobbo created this gist
Jun 22, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ /*CORRECT WORKING FUNCTION TO CONVERT TO BASE 64 AND DISPLAY PREVIEW*/ //var readFile; var previewFile = function() { var preview = document.querySelector('#preview'); var file = document.querySelector('input[type=file]').files[0]; var reader = new FileReader(); reader.onloadend = function() { preview.src = reader.result } if (file) { reader.readAsDataURL(file); } else { preview.src = ''; } } // previewFile() var uploadFile = function() { console.log('uploadFile Clicked') var file = document.querySelector('input[type=file]').files[0]; var reader = new FileReader(); var inputCaption = document.querySelector('#photoCaption').value; /* reader.onloadend = function() { reader.result; }*/ //RUNS AFTER THE READER.READAS...(FILE) IN THE IF STATEMENT. DELIVERS RESULTS AFTER EVERYTHING IS LOADED //SIMILAR TO PROMISE RESOLUTION reader.onloadend = function() { var imgRef = new Firebase('https://familyalbum.firebaseio.com/photos'); imgRef.push({ data : reader.result, caption : inputCaption, }); document.querySelector('#photoCaption').value = ''; } //MAKES SURE THERE IS A FILE SELECTED -- IF THERE IS, READ THE FILE AS A DATAURL -- CAN ACCESS RETURN //VIA READER.RESULT if (file) { console.log("within if statement fired"); reader.readAsDataURL(file); } else { console.log('else fired uploadFile'); } }; // uploadFile()