This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 2nd, 2014  |  syntax: None  |  size: 1.18 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function readURL(input) {
  2.  
  3.     if (input.files && input.files[0]) {
  4.         var reader = new FileReader();
  5.  
  6.         reader.onload = function (e) {
  7.             $('#blah').attr('src', e.target.result);
  8.         }
  9.  
  10.         reader.readAsDataURL(input.files[0]);
  11.     }
  12. }
  13.  
  14. $("#imgInp").change(function(){
  15.     readURL(this);
  16. });
  17.        
  18. <form id="form1" runat="server">
  19.     <input type='file' id="imgInp" />
  20.     <img id="blah" src="#" alt="your image" />
  21. </form>
  22.        
  23. <img id="preview"
  24.              src=""
  25.              alt=""
  26.              style="display:none; max-width: 160px; max-height: 120px; border: none;"/>
  27.  
  28.         <div id="preview_ie">
  29.         </div>
  30.        
  31. #preview_ie {
  32.     FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
  33.   }
  34.        
  35. <script type="text/javascript">
  36.   {% include "pic_preview.js" %}
  37. </script>  
  38. <!--[if gte IE 7]>
  39. <script type="text/javascript">
  40.   {% include "pic_preview_ie.js" %}
  41. </script>
  42.        
  43. function readURL(imgFile)
  44. {    
  45.     var newPreview = document.getElementById("preview_ie");
  46.     newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
  47.     newPreview.style.width = "160px";
  48.     newPreview.style.height = "120px";
  49. }
clone this paste RAW Paste Data