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
Available since 1.1
Return to top