Bahasa

HttpPostedFile.ContentType Properti

Definisi

Mendapatkan tipe konten MIME dari file yang dikirim oleh klien.

public:
 property System::String ^ ContentType { System::String ^ get(); };
public string ContentType { get; }
member this.ContentType : string
Public ReadOnly Property ContentType As String

Nilai Properti

Tipe konten MIME dari file yang diunggah.

Contoh

Contoh kode berikut menunjukkan cara mengulang semua file dalam koleksi file yang diunggah dan mengambil tindakan ketika jenis MIME file adalah US-ASCII.

HttpFileCollection MyFileCollection = Request.Files;

 for (int Loop1 = 0; Loop1 < MyFileCollection.Count; Loop1++)
 {
    if (MyFileCollection[Loop1].ContentType == "video/mpeg")
    {
       //...
    }
 }
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

Berlaku untuk

Lihat juga