Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. $("input:file").change(function(e){
  2. var input=e.target;
  3.  
  4. // create a new FileReader object, and …
  5. var reader=new FileReader();
  6.  
  7. // … tell it what to do in case of it successfully loading the file
  8. reader.onloadend=function(e){
  9. var fileBase64=e.target.result;
  10. $(input).siblings("input:text").first().val(fileBase64);
  11. };
  12.  
  13. // … and have it load the file
  14. reader.readAsDataURL(input.files[0]);
  15. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement