日期:2014-05-18  浏览次数:20687 次

急切求助!上传图片后,马上在文本框中显示图片?
上传图片后,马上在文本框中显示图片?
SQLserver2000库  

给段代码吧   谢谢各位哥哥了!

------解决方案--------------------
页面至少要刷新下吧,要么就用AJAX
------解决方案--------------------
你说的是不是上传完图片(譬如:jpg格式),马上就在同一个页面上显示刚刚上传的小图片??如果是这样的话。我的代码你能用。
<script language=JavaScript>
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width> 0 && image.height> 0){
flag=true;
if(image.width/image.height> = 120/80){
if(image.width> 120){
ImgD.width=120;
ImgD.height=(image.height*120)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+ "× "+image.height;
}
else{
if(image.height> 80){
ImgD.height=80;
ImgD.width=(image.width*80)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+ "× "+image.height;
}
}
/*else{
ImgD.src= " ";
ImgD.alt= " "
}*/
}

function FileChange(Value){
flag=false;
document.all.uploadimage.width=10;
document.all.uploadimage.height=10;
document.all.uploadimage.alt= " ";
document.all.uploadimage.src=Value;
}

function BeforeUpLoad(){
if(flag) alert( "OK ");else alert( "FAIL ");
}

</script>
.
.
.

<TD width= "150 " class= "item "> 登録ファイル </TD>
<TD>
<html:file property= "theFile " style= "WIDTH: 143px; HEIGHT: 18px " onchange= "javascript:FileChange(this.value); " />
<IMG id=uploadimage height=10 width=10 src= " " onload= "javascript:DrawImage(this); " >
</TD>