Using the HttpPostedFile
As stated in the previous section, the HttpPostedFile class enables programmatic access to the uploaded file on the server. This class exposes a number of valuable attributes that you can use to work with the uploaded file and is accessed through the HtmlInputFile's PostedFile property. These attributes include:
ContentLength— This property Gets the size of the uploaded object in bytes. You can use this property to verify that an object was indeed uploaded, and that it doesn't exceed any size restrictions you might have for uploaded files.
ContentType— This property Gets the MIME content type of the object uploaded. You can use this attribute to properly display an image after it is inserted into the database.
FileName ...
Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.