I want to up load image using fileupload and preview the selected image before submit, but it can only work in firefox and IE6. I want to work in IE 7 8 and chrome, also it should work in firefox
<style type="text/css">
#newPreview
{
filter: progidXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);
width: 136px;
height: 134px;
margin-left: 1px;
}
</style>
<script language="javascript" type="text/javascript">
function PreviewImg(imgFile) {
var newPreview = document.getElementById("newPreview");
var src;
if (document.all) {
newPreview.innerHTML = "<img src=\"file:///" + imgFile.value + "\" width=\"130px\">";
}
else {
newPreview.innerHTML = "<img src=\"" + imgFile.files.item(0).getAsDataURL() + "\" width=\"130px\">";
}
}
<form id="form1" runat="Server" method="post" enctype="multipart/form-data">
<div id="newPreview">
<asp:FileUpload ID="file" runat="server" size="20" Width="129px"
onchange="PreviewImg(this)"/>