Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  7. </head>
  8.  
  9. <body>
  10. <div id="upload-image-preview">
  11. >>>>>> PICTURE WILL REPLACE THIS CONTENT <<<<<<
  12. </div>
  13. <hr/>
  14. <input id="pic-inp" type="file" name="pic" accept="image/*">
  15. <script>
  16. $("#pic-inp").change(function () {
  17. if (this.files && this.files[0]) {
  18. var reader = new FileReader();
  19.  
  20. reader.onload = function (e) {
  21. var img = $('<img>').attr('src', e.target.result);
  22. $('#upload-image-preview').html(img);
  23. };
  24.  
  25. reader.readAsDataURL(this.files[0]);
  26. }
  27. });
  28. </script>
  29. </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement