如何用js判断商传图片的高度和宽度??特别急!!

xmlkiller 2003-10-17 04:37:43
如何用js判断商传图片的高度和宽度??特别急!!
...全文
26 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xmlkiller 2003-10-17
  • 打赏
  • 举报
回复
包错了,10行
aocool 2003-10-17
  • 打赏
  • 举报
回复
<SCRIPT language=javascript>
function index_image_valid(){
var img=new Image();
var tout;
window.clearTimeout(tout);
img.src=document.pho_up.pho_index.value;
imagewidth=img.width;
imageheigth=img.height;
fsize=img.fileSize/1024;
fsize=fsize.toFixed(1);
document.pho_up.cmd.disabled=true;
if(img.readyState!="complete")
tout=window.setTimeout("index_image_valid()",10);
else
{alert ("宽:"+imagewidth+"\n高:"+imageheigth+"\n大小:"+fsize+" KB");
document.pho_up.cmd.disabled=false}
}
</script>
</head>
<form name="pho_up" method="post" enctype="multipart/form-data">
<input type="file" name="pho_index" size="20">
<input type=button name="cmd" value="测试图片大小" onclick="index_image_valid();">
</form>

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧