[转]ASP.NET如何获取上传图片尺寸(是指宽高)
1.采用客户端javascript可以取得图片大小
<input id="FileUpload" type="file" size="27" name="FileUpload" onpropertychange="javascript:img2.src=this.value;">
<img id="img2" src="" style="visibility:hidden;position:absolute;top=-10000"/>
<input type="button" value="获取" onclick="javascript:abc();">
<script language="javascript">
function abc()
{
alert(img2.width);
}
2.采用流取得图片大小
Stream stream=file.PostedFile.InputStream;
System.Drawing.Image image=System.Drawing.Image.FromStream(stream);
Image.Width
Image.Height
3.使用文件得到图片大小
System.Drawing.Image image=System.Drawing.Image.FromFile(图片路径)
Image.Width
Image.Height