aspx怎么获得上传图片的宽和高
程序员文章站
2022-05-25 21:46:56
...
https://zhidao.baidu.com/question/252185066.html
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