Export (0) Print
Expand All

HttpPostedFile.ContentType Property

Gets the MIME content type of a file sent by a client.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public string ContentType { get; }

Property Value

Type: System.String
The MIME content type of the uploaded file.

The following code example shows how to loop through all the files in the uploaded file collection and take action when the MIME type of a file is US-ASCII.

HttpFileCollection MyFileCollection = Request.Files;

 for (int Loop1 = 0; Loop1 < MyFileCollection.Count; Loop1++)
 {
    if (MyFileCollection[Loop1].ContentType == "video/mpeg")
    {
       //...
    }
 }
    

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft