How do you convert a HttpPostedFileBase to an Image?
问题 I am using ASP.NET MVC and I've an action that uploads the file. The file is being uploaded properly. But I want width and height of the image. I think I need to convert the HttpPostedFileBase to Image first and then proceed. How do I do that? And please let me know if there is another better way to get the width and height of the image. 回答1: I use Image.FromStream to as follows: Image.FromStream(httpPostedFileBase.InputStream, true, true) Note that the returned Image is IDisposable . You'll