Get file size in javascript for IE

Thread is closed for posting
3 posts, 0 answers
  1. Mansi
    Mansi avatar
    63 posts
    Member since:
    Feb 2009

    Posted 04 Feb 2011 Link to this post

    I am using mulitple uploader, and need to get the file size at client side when user selects the file.
    Is there any direct method or property to get size?
    For now I am using the below code, but it is not working in IE

     function selectedFile(sender, eventArgs) {
       var inputs = sender.getFileInputs();
       for (i = 0; i < inputs.length; i++) {
                        if (navigator.appName == "Netscape") {
                            size = inputs[i].files[0].fileSize;
                   else if (navigator.appName == "Microsoft Internet Explorer") {                  
                            var filepath = inputs[i].value;
                            var SizeINIE = User_book.GetFileSize(filepath);     //This always returns 0 as the file will not be existing on server
                            if (SizeINIE != null) {
                                size = SizeINIE.value;
    Can anyone provide me solution for this ASAP?
  2. Dimitar Terziev
    Dimitar Terziev avatar
    1268 posts

    Posted 10 Feb 2011 Link to this post

    Hi Mansi,

    The problem you are experiencing is due to the fact that IE doesn't support this kind of functionality in general.
    As you have noticed this is working in Firefox and Chrome but for now there is now way to achieve this functionality with IE.

    Kind regards,
    Dimitar Terziev
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Angel
    Angel avatar
    1 posts
    Member since:
    Jan 2013

    Posted 01 Jan 2013 Link to this post

    Actually there is something I`d call a non-solution - it does require you to create a non-secure activeX object:
    var filesystem=new ActiveXObject('Scripting.FileSystemObject'),
    fullpath=value_of_the_file_input_dom_element;// you know how to get this
    var size_bytes=filesystem.getFile(fullpath).size;
    M$$ tries to create everything in it`s "own" way. For this to work, you need to select "Initialize and script active x controls not marked safe for scripting" in Security->CustomLevel

Back to Top