FileUpload上传图片(图片不变形)
<style type="text/css">
#newPreview
{
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=images);
}
</style>
<script type="text/javascript" language="javascript">
function PreviewImg(imgFile)
{
var newPreview = document.getElementById("newPreview");
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
newPreview.style.width = newPreview.offsetWidth /2;
newPreview.style.height = newPreview.offsetHeight / 2;
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = 'scale';
}
</script>
请选择一个图片进行预览:
<input type="file" size="20" onchange="javascript:PreviewImg(this);" />
<div id="newPreview"></div>