How can i get the content type of uploaded files

Last post 05-27-2009, 10:41 PM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  05-27-2009, 5:58 AM 52544

    How can i get the content type of uploaded files

    hi,

    I am using ajax uploader to upload files in my application. It works fine, but my problem is "How to get the contentType of uploaded files?". Asp.net upload controls has contentType property.
     
    This is important for me since i used it to show the files.
    eg,
     
    Response.ContentType = contentType
    Response.OutputStream.Write(fileContent, 0, fileSize)
     
    Thanks in advance.
    Filed under:
  •  05-27-2009, 10:41 PM 52569 in reply to 52544

    Re: How can i get the content type of uploaded files

    Hi,
     
    The content type is from client and not trust-able.
     
    You can determine the content type from the file extenstion.
     
    Please check our advanced example:
     
    App_Code\SampleUtill.cs
    static public string GetMimeType(string filename)
     
    Regards,
    Terry
     
View as RSS news feed in XML