Oct 11
14
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:
-
jQuery("#upload_files1").submit(function(){
-
jQuery(‘input:file[value=""]‘).attr("disabled", true);
-
});
and the form:
-
-
<form id="upload_files1" enctype="multipart/form-data" method="post">
-
<input name="img[]" type="file" />
-
<input name="img[]" type="file" />
-
…
-
<input name="img[]" type="file" />
-
<input name="save" type="submit" value="Save" />
-
</form>
