ASP.net 上传图片,并及时显示
使用 AjaxControlToolkit.AsyncFileUpload 进行上传图片,但是文件上传了,不在画面里显示图片,
--------------------编程问答--------------------
看效果
--------------------编程问答--------------------
<HTML>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<HEAD>
<TITLE> Test Page </TITLE>
</HEAD>
<BODY>
<script>
function preview(imgFile,num)
{
//预览代码,支持 IE6、IE7。
var newPreview = document.getElementById("preview1");
document.getElementById("img1").src=imgFile.value;
var t ;
if(document.all) //IE
t = imgFile.value;
else
t = imgFile.files[0].getAsDataURL(); //FF
newPreview.style.backgroundImage = "url(" + t + ")";//imgFile.value;
newPreview.style.width = "108px";
newPreview.style.height = "130px";
newPreview.style.display = "block";
}
</script>
<input type="file" onchange='ShowImg(this)' />
<div id="preview1" style="border:1px solid #FFCC00; width:108px; height:130px;display:block" >
</div>
<img id="img1" name="img1" width="142" height="170" >
<script>function ShowImg(o)
{
//var Browser_Agent=navigator.userAgent;
//if(Browser_Agent.indexOf("Firefox")!=-1)
//{
//火狐使用
// document.getElementById("idImg").src=o.files[0].getAsDataURL();
// document.getElementById("idImg").style.display = "block";
// }
//else
//{
preview(o,1);
//}
} </script>
</BODY>
</HTML>
--------------------编程问答--------------------
<HTML>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<HEAD>
<TITLE> Test Page </TITLE>
</HEAD>
<BODY>
<script>
function preview(imgFile,num)
{
//预览代码,支持 IE6、IE7。
var newPreview = document.getElementById("preview1");
document.getElementById("img1").src=imgFile.value;
var t ;
if(document.all) //IE
t = imgFile.value;
else
t = imgFile.files[0].getAsDataURL(); //FF
newPreview.style.backgroundImage = "url(" + t + ")";//imgFile.value;
newPreview.style.width = "108px";
newPreview.style.height = "130px";
newPreview.style.display = "block";
}
</script>
<input type="file" onchange='ShowImg(this)' />
<div id="preview1" style="border:1px solid #FFCC00; width:108px; height:130px;display:block" >
</div>
<img id="img1" name="img1" width="142" height="170" >
<script>function ShowImg(o)
{
//var Browser_Agent=navigator.userAgent;
//if(Browser_Agent.indexOf("Firefox")!=-1)
//{
//火狐使用
// document.getElementById("idImg").src=o.files[0].getAsDataURL();
// document.getElementById("idImg").style.display = "block";
// }
//else
//{
preview(o,1);
//}
} </script>
</BODY>
</HTML>
--------------------编程问答--------------------
上传控件
补充:.NET技术 , ASP.NET