how to get file size through javascript without using Activex Object

Posted on 2009-04-23
Last Modified: 2012-08-13
   How to get the upload file size through javascript.
I am not using ActiveX object as this object is not supported by all browsers.

<form name="formCompanyLogo" action="companyUpload.jsp" method="post"
<input type="file" name="file" id="submitfileForCompanyLogo" value="browse"  />  <input       name="input" type="submit" id="input" value="Upload"
      onclick="return upLoadLogoImage();" /></form>

plz help me asap...

thnx in advance....
Question by:emsysindia
    LVL 16

    Accepted Solution

    I dont think you will be able to get the file size just by using javascript. ActiveX was one option but since you do not want to use that your only option would be to get the file size after uploading the file to the server using JSP.
    LVL 39

    Assisted Solution

    I'm afraid I have bad news for you: directly, through javascript, is not possible. What you can do, however (similar to the EE upload facility), is using ajax-style technique or using an IFrame (the latter is what is used at EE).

    The trick is as follows: the file is uploaded and the server returns a piece of html/xml that contains the filesize. On the server side you can use your regular methods to extract the filesize.
    LVL 39

    Expert Comment

    Abandoning a question and then checking back with a lower grade is considered poor behavior on EE. Please reconsider your grade or check back with what you need clarification on.

    An answer that something cannot be done should not influence your grading, not even if you are disappointed about the limits of a certain technology. I'm also disappointed that my car cannot fly, but if someone explains me that, is that a bad messenger?

    Problems with closing questions? Check this:

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (, typical array handling might look like this: (CODE) B…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now