2012-03-03 83 views
0

我想在上傳前將圖像比較爲asp.net中文件上傳控件中的x乘y像素 如何使用javascript以像素爲單位獲取圖像大小?讓JavaScript中的圖像尺寸使用javascript確定圖像大小(以像素爲單位)

+1

可能dublicate http://stackoverflow.com/問題/ 623172 /如何到獲取圖像尺寸,高寬使用的JavaScript – dotoree 2012-03-03 10:56:18

回答

0

在firefox中,你可以通過這種方法獲取文件路徑:

https://developer.mozilla.org/en/DOM/File.getAsDataURL

或最新版本:

window.URL.createObjectURL(file); 

的WebKit的 window.webkitURL.createObjectURL() 見 https://developer.mozilla.org/en/Document_Object_Model_(DOM)/window.URL.createObjectURL

並將其設置爲一個img標籤,並獲得大小。
爲即你shoule設置一個過濾器的ELEM

progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image) 

,並設置網址到這個過濾器,那麼你可以得到IMG的大小 好運

相關問題