TheNorthFace TheNorthFace - 1 year ago 90
Javascript Question

HTML form with multiple file upload fields, how to check max file size client side

I have this simple script that checks max file size client side in a html form. The check works for the first file added, but I'm having a struggle finding out how to apply the method for checking the other input fields as they are dynamically added.

The check is based on

var uploadField = document.getElementById("file1");

Check out this fiddle to better understand the issue:

Any tips on how to solve this would be much appreciated.

Answer Source

Do a check for total number of File Input items and validate. Updated

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download