HttpPostedFile hp = FileUpload1.PostedFile;//创建访问客户端上传文件的对象
Stream sr = hp.InputStream;
System.Drawing.Image image = System.Drawing.Image.FromStream(sr);
int width = image.Width;
int height = image.Height;
string ext = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
image.Dispose();
if (width > 40 || height > 40 || ext != ".png")
{
string strErrMsg = "alert('图片允许上传小于 40像素x40像素 的PNG文件.\\r\\n')";
Response.Write(JS.RegJs(strErrMsg));
//FileUpload1.Dispose();
}
微信关注 奔跑的GISer 获取更多资源