Compare mime type againt file extension

Thread is closed for posting
2 posts, 0 answers
  1. Foppa
    Foppa avatar
    9 posts
    Member since:
    Apr 2007

    Posted 18 Feb 2013 Link to this post

    How can I validate that the file I have uploaded has right mime type if compared with the file extension?

    I want to support all browsers. It means well that I must do the validation on the server. Or?
    And how should I do?

    Right now I use RadUpload and validates against the file extensions, it works well. But like I say I also want to make sure that the file extension matches the mine type.

    Grateful for the tips!
    Best regards,

  2. Plamen
    Plamen avatar
    2725 posts

    Posted 21 Feb 2013 Link to this post

    Hello Foppa,

    You can set the AllowedMimeTypes programmatically as it is done in the code behind in this on-line demo but different browsers serve different MIME types for the same files and as it is explained here RadUpload does not determine the mime-type using only the file extension. For example if you try to upload a text file that has the extension ".JPG", it is still uploaded with text/plain mime-type.

    Hope this will explain the issue.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top