【发布时间】:2011-07-09 21:21:16
【问题描述】:
可能的重复:
get image height and width in file tag javascript
Determining image file size + dimensions via Javascript?
How to upload preview image before upload through JavaScript
如何在文件标签中不刷新页面的情况下获取图像的高度和宽度?
<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
function getW()
{
var theImg = document.getElementById('testimg');
alert(theImg.width);
}
function getH()
{
var theImg = document.getElementById('testimg');
alert(theImg.height);
}
</script>
</HEAD>
<BODY>
<input type="file" id="testimg"/>
<input type="button" value="get Width" onclick="getW()"/>
<input type="button" value="get Height" onclick="getH()"/>
</BODY>
</HTML>
我使用 php 代码获取图像的图像高度和宽度,但是那个时候页面将被刷新,没有页面刷新我得到图像大小但不是高度和宽度....
【问题讨论】:
-
懒惰? 2个这样的问题一个接一个? stackoverflow.com/questions/6633190/…
标签: javascript