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 ReadOnly Property ContentType As String

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.

Dim Loop1 As Integer
 Dim MyFileCollection As HttpFileCollection = Request.Files

 For Loop1 = 0 To MyFileCollection.Count - 1
    If MyFileCollection(Loop1).ContentType = "video/mpeg" Then
       '...
    End If
 Next Loop1

.NET Framework
Available since 1.1
Return to top
Show: