<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN"
"http//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type = "text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<input type='file' onchange="readURL(this);" />
<img id="blah" src="#" width = "300px" max-height = "340px" alt="your image" />
</form>
</body>
</html>
5 Replies - 620 Views - Last Post: 24 May 2012 - 10:18 PM
#1
Cross browser compatibility issues with image preview script.
Posted 24 May 2012 - 12:17 PM
Hello, It's my first time attempting this. After searching around the web, I came across this script which does what I'm trying to accomplish (ie preview a picture before it is downloaded) but only works for Firefox and Opera. Does anyone know how this code can be modified to make it cross browser compatible? Or does anyone have a better working example? Thanks.
Replies To: Cross browser compatibility issues with image preview script.
#3
Re: Cross browser compatibility issues with image preview script.
Posted 24 May 2012 - 01:07 PM
Only in IE10, though, it appears. I don't see a way to use that IE9 Lab stuff with an input element.
#4
Re: Cross browser compatibility issues with image preview script.
Posted 24 May 2012 - 04:15 PM
@drmilich and atli, have u fellows tested it in your browsers? Just in case I might be using outdated versions though I don't think so.
#5
Re: Cross browser compatibility issues with image preview script.
Posted 24 May 2012 - 10:09 PM
Yea, I tested it in all the browsers I have at home, and it works in all but IE and Safari.
That is, it works in:
- Firefox 12.0
- Chrome 19.0 and 20.0 (beta)
- Opera 11.61
But not in:
- Internet Explorer 9
- Safari 5.1.3 (OSX)
That is, it works in:
- Firefox 12.0
- Chrome 19.0 and 20.0 (beta)
- Opera 11.61
But not in:
- Internet Explorer 9
- Safari 5.1.3 (OSX)
#6
Re: Cross browser compatibility issues with image preview script.
Posted 24 May 2012 - 10:18 PM
Guess I should have done some Googling before testing it myself 
When can I use FileReader API?
By the way, MDN is wrong in their browser support table. Safari 5.1 does NOT support the FileReader API.
When can I use FileReader API?
By the way, MDN is wrong in their browser support table. Safari 5.1 does NOT support the FileReader API.
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote




|