File ContentType for .zip file is null

7 posts, 1 answers
  1. Rakesh
    Rakesh avatar
    7 posts
    Member since:
    Apr 2015

    Posted 15 Jul 2015 Link to this post

    Hello All

    I am using RadAsyncUpload and using a custom HTTPHandler and inserting the files directly to DB. Before inserting I am checking for the MIME Type of the file. I am getting the MIME type from Uploadedfile.ContentType. This is returning NULL for .zip file.I am using IE 10 and the version of Telerik is 2014.3.1024.35

    Any help is much appreciated.

    Thanks

    Rakesh

  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 20 Jul 2015 Link to this post

    Hi Rakesh,

    Are you using Google Chrome? This look like a bug in Chrome. It can be reproduced with the following hmtl:

    <!DOCTYPE html>
    <head>
        <title></title>
    </head>
    <body>
        <div>
            Select .zip file.
        </div>
        <input type="file" id="fileInput" onchange="fileSelected()" />
     
        <script type="text/javascript">
            function fileSelected() {
                var input = document.getElementById('fileInput');
                var file = input.files[0];
                alert(file.type);
            }
        </script>
    </body>
    </html>

    I have logged this issue to Google - Web API Blob.Type returns empty mime type when zip file is selected. 
    But this what is more interesting here is that IE10/11 also returns empty mime type for zip files.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rakesh
    Rakesh avatar
    7 posts
    Member since:
    Apr 2015

    Posted 20 Jul 2015 in reply to Hristo Valyavicharski Link to this post

    Hi Hristo

    Thank you for the reply. I didn't try it in Chrome. But this is happening in IE10. Looks like you too have the same issue in IE10/11. Do you have any alternative approach for this?

     

    Thanks

    Rakesh

  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 20 Jul 2015 Link to this post

    No unfortunatelly. But you could try to get the content type by the file extension.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Rakesh
    Rakesh avatar
    7 posts
    Member since:
    Apr 2015

    Posted 20 Jul 2015 in reply to Hristo Valyavicharski Link to this post

    I have the extension. But I need the MIME type for some validation.
  7. Answer
    Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 20 Jul 2015 Link to this post

    Since this is a bug in browser's File API implementation try to disable the AsyncUpload File API module:

    <telerik:RadAsyncUpload runat="server" ID="upload" DisablePlugins="true"
          HttpHandlerUrl="~/AsyncHandler.ashx"></telerik:RadAsyncUpload>
    <script type="text/javascript">
           Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable = function () { return false; }
     
       </script>

    I hope this helps.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Rakesh
    Rakesh avatar
    7 posts
    Member since:
    Apr 2015

    Posted 20 Jul 2015 in reply to Hristo Valyavicharski Link to this post

    This is working perfect in IE10. I am not sure how this behaves in chrome. Thank you for the help.

     

    Thanks

    Rakesh

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017