Created
October 20, 2016 11:14
-
-
Save christophfink/cb5b2959dc64aad77ab5e6de66f67263 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
$("input:file").change(function(e){ | |
var input=e.target; | |
// create a new FileReader object, and … | |
var reader=new FileReader(); | |
// … tell it what to do in case of it successfully loading the file | |
reader.onloadend=function(e){ | |
var fileBase64=e.target.result; | |
$(input).siblings("input:text").first().val(fileBase64); | |
}; | |
// … and have it load the file | |
reader.readAsDataURL(input.files[0]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment