0

The code given below work fine with firefox but not not with ie....

<script language="javascript">
function findSize() {
    var fileInput =  document.getElementById("filename");

    f_size=fileInput.files[0].size; // Size returned in bytes.
    if(f_size>=2000000)
    {
        alert("File Should be less than or equel to 2MB");
        return false;
    }
    return true;   
}

give any solution

10
  • IE doesn't support the .files collection, nothing you can do about it Commented Mar 27, 2014 at 8:51
  • Try to look for errors in your console... Commented Mar 27, 2014 at 8:51
  • use firebug, and see what errors show up Commented Mar 27, 2014 at 8:53
  • @AmitApollo Firebug in IE. Fantastic. It's not like IE has had fully-functional Developer Tools since IE8. Commented Mar 27, 2014 at 8:54
  • @Niet, "Fully-functional"... HAHAHAHA, best laugh I've had this morning - it's awful, and every time I've tried to us it I've ended up killing the IE process. Commented Mar 27, 2014 at 8:56

1 Answer 1

2

Unfortunately, depending on the IE version you cannot use the latest JavaScript APIs and cannot access that information.

The solution is to stop using IE or parse that information on the server-side. I highly recommend the former.

Please see http://caniuse.com/ for the availability of JavaScript APIs for various browser versions.

Sign up to request clarification or add additional context in comments.

4 Comments

How many web developers do you think have the ability to MAKE their users "stop using IE"?? It would be great, but that's not exactly a helpful statement
Nice site, but unless I'm being really stupid, where is the information for the .files collection?
maybe add the HTML in the question where you reference the DOM element filename. It'd help to see the surrounding code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.