<
html
>
< head >
< meta http-equiv ="content-type" content ="text/html; charset=gb2312" >
< script language ="javascript" type ="text/javascript" >
// 转变图片的方法。主要思想:在文件上传标签上方放一个DIV用于控制图片的显示。
// 当用户选择图片地址后,将地址传给DIV下的img标签,从而让图片显示出来。
function change_photo(obj,width,height)
{
var imgDIV = document.getElementById("imgDIV");
var str = obj.value || obj;
try{
imgDIV.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = str;
imgDIV.style.width=width;
imgDIV.style.height=height;
imgDIV.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = 'scale';
document.getElementById('img').style.display = "none";
}catch(e){
// 上传不是图片文件的处理。
}
}
</ script >
</ head >
< body >
< div id ="imgDIV" style ="width:258px;height:63px;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);
text-align: center;" >
< img ID ="img" height ="300px" Width ="500px" nerror ="change_photo(this.src,140,70);" >
</ div >
< input type ="file" name ="files" style ="width: 115px" styleClass ="TEXT04"
onchange ="change_photo(this,500,300);" />
</ body >
</ html >
< head >
< meta http-equiv ="content-type" content ="text/html; charset=gb2312" >
< script language ="javascript" type ="text/javascript" >
// 转变图片的方法。主要思想:在文件上传标签上方放一个DIV用于控制图片的显示。
// 当用户选择图片地址后,将地址传给DIV下的img标签,从而让图片显示出来。
function change_photo(obj,width,height)
{
var imgDIV = document.getElementById("imgDIV");
var str = obj.value || obj;
try{
imgDIV.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = str;
imgDIV.style.width=width;
imgDIV.style.height=height;
imgDIV.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = 'scale';
document.getElementById('img').style.display = "none";
}catch(e){
// 上传不是图片文件的处理。
}
}
</ script >
</ head >
< body >
< div id ="imgDIV" style ="width:258px;height:63px;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);
text-align: center;" >
< img ID ="img" height ="300px" Width ="500px" nerror ="change_photo(this.src,140,70);" >
</ div >
< input type ="file" name ="files" style ="width: 115px" styleClass ="TEXT04"
onchange ="change_photo(this,500,300);" />
</ body >
</ html >