TheNorthFace TheNorthFace - 5 months ago 8
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: http://jsfiddle.net/tZPg4/16341/

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

Answer

Do a check for total number of File Input items and validate. Updated http://jsfiddle.net/zz8c9c9u/5/

Comments