Guest User

Untitled

a guest
Oct 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4.  
  5. <link rel="stylesheet" href="css/miestilos.css">
  6. <script
  7. src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
  8. </script>
  9. </head>
  10. <body>
  11. <div>
  12. <input type="file" id="files" />
  13. <output id="list"></output>
  14. </div>
  15. <div id="altura">Altura</div>
  16. <div id="anchura">Anchura</div>
  17.  
  18. <script type="text/javascript" src= "js/app.js"></script>
  19.  
  20. </body>
  21. </html>
  22.  
  23. $(document).ready(function() {
  24. function handleFileSelect(evt) {
  25. var files = evt.target.files; // FileList object
  26.  
  27. // Loop through the FileList and render image files as thumbnails.
  28. for (var i = 0, f; f = files[i]; i++) {
  29.  
  30. // Only process image files.
  31. if (!f.type.match('image.*')) {
  32. continue;
  33. }
  34.  
  35. var reader = new FileReader();
  36.  
  37. // Closure to capture the file information.
  38. reader.onload = (function(theFile) {
  39. return function(e) {
  40. // Render thumbnail.
  41. var span = document.createElement('span');
  42. document.getElementById('list').innerHTML='';
  43. span.innerHTML = ['<img class="center" id="imagen" src="', e.target.result,
  44. '" title="', escape(theFile.name), '"/>'].join('');
  45.  
  46.  
  47. document.getElementById('list').insertBefore(span, null);
  48. };
  49.  
  50. })(f);
  51.  
  52.  
  53. // Read in the image file as a data URL.
  54. reader.readAsDataURL(f);
  55. }
  56. }
  57.  
  58. document.getElementById('files').addEventListener('change', handleFileSelect, false);
  59.  
  60.  
  61.  
  62. });
Add Comment
Please, Sign In to add comment