Get File Content Type

Last post 02-13-2009, 8:53 AM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  02-12-2009, 10:47 AM 48670

    Get File Content Type

    Hello,
     
    I am loading these files to a sql server database and I need to know the file content type for when I go to stream them back out.
     
    Example (application/pdf)
     
    With the asp:FileUpload control you would do something like
    Dim
    myVar As String = FileUpload1.PostedFile.ContentType
     
    Thanks,
    b-man
  •  02-13-2009, 8:53 AM 48747 in reply to 48670

    Re: Get File Content Type

    b-man,
     
    For security reason. Uploader do not provide that property .
     
    You can determine the mimetype from the file extension.
     
    Please check our sample code , Ajax-Uploader\AdvancedCS20-MicrosoftAjax\App_Code\SampleUtill.cs
     
    the static public string GetMimeType(string filename) show you how to get the mimetype of a file.
     
    --
     
    Maybe we can collect all the relation and provide that property by filename, but we would not allow the value from client.
     
    Regards,
    Terry
     
View as RSS news feed in XML