可能重複:
Determining image file size + dimensions via Javascript?
How to upload preview image before upload through JavaScript
get image height and width in file tag using javascript獲得圖像的高度和寬度標籤在文件的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代碼,但那個時候頁面將會被刷新,而無需刷新頁面,我得到的圖像大小,但不是一個高度和寬度....
同樣的問題? - > http://stackoverflow.com/questions/6633190/get-image-height-and-width-in-file-tag-javascript – Pwnna