display pictures before upload not working in ie9

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mdviky87
    New Member
    • Oct 2012
    • 2

    #1

    display pictures before upload not working in ie9

    Working in Chrome, Firefox.


    Code:
    <html>
    <head>
    <title>ThaiCreate.Com Tutorial</title>
      <script src="http://code.jquery.com/jquery-latest.js"></script>
    </head>
    <body>
    <form name="frmMain" action="" method="post">
    <script language="JavaScript">
    	function showPreview(ele)
    	{
    			$('#imgAvatar').attr('src', ele.value); // for IE
                if (ele.files && ele.files[0]) {
    			
                    var reader = new FileReader();
    				
                    reader.onload = function (e) {
                        $('#imgAvatar').attr('src', e.target.result);
                    }
    
                    reader.readAsDataURL(ele.files[0]);
                }
    	}
    </script>
    <input type="file" name="filUpload" id="filUpload" OnChange="showPreview(this)">
    <input type="submit" name="btnSubmit" value="Submit">
    <hr>
    <img id="imgAvatar">
    </form>
    </body>
    </html>
    Attached Files
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    IE9 is not capable of this feature. It doesn't support the FileReader API, nor will it allow you to load stuff of the hard drive using a local file path. (That could easily become a security nightmare.)

    Comment

    Working...