$_FILES limitation when uploading files in PHP

Along with the “upload_max_filesize” when uploading files with PHP there is another parameter named “max_file_uploads” witch prevent uploading more files that the value of this parameter.

Default size of this parameter is 20 and is should be enough for more apps then I can count but today I had to repair a bug in a page where a form contain 30 file uploads and just 20 were availble in $_FILES from php script.

How can you change this?

There are 2 methods. One is to change it from php.ini but not always you can access php.ini file

The second method is not using ini_set :( . Tried that and not working.

I did find another method witch need some javascript. The method is when submiting the form a javascript will disable all unused upload elements like this:

  1. jQuery("#upload_files1").submit(function(){
  2.     jQuery(‘input:file[value=""]‘).attr("disabled", true);
  3. });

and the form:

  1.  
  2. <form id="upload_files1" enctype="multipart/form-data" method="post">
  3. <input name="img[]" type="file" />
  4. <input name="img[]" type="file" />
  5. <input name="img[]" type="file" />
  6. <input name="save" type="submit" value="Save" />
  7. </form>

Tags: , , , , ,

Comments are closed.