ASP.NET上传图片立即显示(不上传到服务器)
在页面加入如下代码
<style type="text/css">#newPreview {
FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
}
</style>
<script language="javascript" type="text/javascript">
function PreviewImg(imgFile)
{
var newPreview = document.getElementById("newPreview");
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
newPreview.style.width = "120px";
newPreview.style.height = "168px";
}
</script>
在FileUpload 里加入下面事件
<asp:FileUpload ID="file_image" runat="server" onchange="PreviewImg(this)" />
<div id="newPreview"></div>