$_FILES limited to 20 files?
Posted: Wed May 12, 2010 3:08 am
This is something I hadn't seen documented so I thought I would post here to confirm this.
I've been building a file uploader for administrative purposes. I had originally hardcoded a 99 file limit (as an arbitrary "more than you can really use" kind of number, but ran into an issue where php (through $_FILES) does not accept more than 20 files at a time. Since this is an image uploader with optional manual thumbnails, that's effectively 10 images at a time. I suppose I can live with that, but would like to know if anybody knows whether this is due to some obscure setting I can change, a hard limit in php, or something to do with my server setup (currently running PHP5/Apache/Linux).
I thought it might be nice to provide some test code so people with different setups can see what the limit is on their configurations. To that end:
file_limit_test.php
When testing this, you don't need to actually fill out the form as $_FILES will return data even for empty boxes. In other words, just hit submit and view the results.
Results on my end (note only File0 - File19 are returned):
[text]
Array
(
[File0] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File1] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File2] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File3] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File4] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File5] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File6] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File7] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File8] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File9] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File10] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File11] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File12] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File13] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File14] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File15] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File16] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File17] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File18] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File19] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
[/text]
I've been building a file uploader for administrative purposes. I had originally hardcoded a 99 file limit (as an arbitrary "more than you can really use" kind of number, but ran into an issue where php (through $_FILES) does not accept more than 20 files at a time. Since this is an image uploader with optional manual thumbnails, that's effectively 10 images at a time. I suppose I can live with that, but would like to know if anybody knows whether this is due to some obscure setting I can change, a hard limit in php, or something to do with my server setup (currently running PHP5/Apache/Linux).
I thought it might be nice to provide some test code so people with different setups can see what the limit is on their configurations. To that end:
file_limit_test.php
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
$UploadTest_Submit = "";
import_request_variables("P", "UploadTest_");
if ($UploadTest_Submit == "Submit")
{
echo "<pre>";
print_r($_FILES);
echo "</pre>";
} else
{
echo "<form action=\"file_limit_test.php\" method=\"post\" name=\"ImageUpload\" enctype=\"multipart/form-data\">\n";
echo "<INPUT type=\"submit\" alt=\"Submit\" name=\"Submit\" value=\"Submit\"><br>\n<br>\n";
for ($i = 0; $i < 100; $i++)
{
echo "<input type=\"file\" name=\"File$i\" alt=\"File Path\" size=\"55\"><br>\n<br>\n";
echo "<br>\n";
};
echo "</form>\n";
};
?>
</body>
</html>
Results on my end (note only File0 - File19 are returned):
[text]
Array
(
[File0] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File1] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File2] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File3] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File4] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File5] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File6] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File7] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File8] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File9] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File10] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File11] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File12] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File13] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File14] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File15] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File16] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File17] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File18] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
[File19] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
[/text]