对于asp.net2.0中的fileupload控件,在后台得如何得到上传的文件的长和宽呀?

解决方案 »

  1.   

    文件有长和宽?那么你说的 Word 文档有多宽呢?
      

  2.   

    long len = FileUpload.FileContent.Length;
      

  3.   

    HttpFileCollection hc = HttpContext.Current.Request.Files;
                        HttpPostedFile hp = hc[0];
                        string num = UploadFile.PostedFile.FileName;
                        int i = num.LastIndexOf('.');
                        string newtype = num.Substring(i);
                        string newname = DateTime.Now.ToString("yyyyMMddHHmmss") + UploadFile.PostedFile.ContentLength;
                        b = new System.Drawing.Bitmap(hp.InputStream);                    if (b.Width > 100) //这里可以获取图片的宽度
                        {
                            newwidth = 100;
                            newheight = (b.Height * newwidth) / b.Width;
                            System.Drawing.Image img = b.GetThumbnailImage(newwidth, newheight, null, IntPtr.Zero);
                            img.Save(Server.MapPath("images/SmallImage/" + newname + newtype), System.Drawing.Imaging.ImageFormat.Jpeg);                    }
                        else
                        {
                            UploadFile.PostedFile.SaveAs(Server.MapPath("images/SmallImage/" + newname + newtype));
                        }
      

  4.   

    对于图片,你得读取文件流,用 System.Drawing.Bitmap 加载,即可获取 width height
      

  5.   

    http://community.csdn.net/Expert/topic/5705/5705229.xml?temp=.4674341
    这个贴子,高手帮助回一下,.
      

  6.   

    对上传的是图片,System.Drawing.Bitmap这个对象没有 width height属性呀?