Advertisement
Kalashnikov

Untitled

Sep 12th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CSS (just an example, duh)
  2.   img#thumbnail {\
  3.         display: none;\
  4.         position: fixed;\
  5.         right: 10px;\
  6.         top: 35px;\
  7.         max-width: 380px;\
  8.         max-height: 200;\
  9.         border-shadow: black 0 0 15px;\
  10.         opacity: .7;\
  11.       }\
  12.       img#thumbnail:hover{\
  13.           opacity: 1;\
  14.       }\
  15.  
  16.  
  17. var img = document.createElement('img');
  18.     img.id = 'thumbnail';
  19.     document.body.appendChild(img);
  20.    
  21.     var finput = $('input[name="upfile"]');
  22.     finput.addEventListener('change', function(e) {
  23.         var f = e.target.files[0];
  24.         //console.log('File changed, new file: '+f.name);
  25.         if (!f) {
  26.             $('img#thumbnail').style.display = 'none';
  27.             return;
  28.         }
  29.         var r = new FileReader();
  30.         r.onload = function(e) {
  31.             $('img#thumbnail').src = e.target.result;
  32.             $('img#thumbnail').style.display = 'block';
  33.         }
  34.         r.readAsDataURL(f);
  35.     }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement