Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I detect the MIME type of an uploaded file in ASP.NET?

Tags:

How do people usually detect the MIME type of an uploaded file using ASP.NET?

like image 702
c.sokun Avatar asked Sep 17 '08 08:09

c.sokun


People also ask

What is MIME type detection?

MIME detection This uses the GNU file utility to determine the type of the file, which should work right away under Linux. Note that the file utility provided by other Unixes may not support the -i option, and will thus not work.

What is MIME type in asp net?

A media type, also called a MIME type, identifies the format of a piece of data. In HTTP, media types describe the format of the message body. A media type consists of two strings, a type and a subtype. For example − text/html.


1 Answers

in the aspx page:

<asp:FileUpload ID="FileUpload1" runat="server" /> 

in the codebehind (c#):

string contentType = FileUpload1.PostedFile.ContentType 
like image 166
Kinjal Dixit Avatar answered Sep 18 '22 13:09

Kinjal Dixit