Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $_FILE array missing entries from submitted HTML form

Basically when I have more than about 25 file uploads in one form, the PHP $_FILES array is cropped to the first 25 entries (0-24), which is incorrect. It should have all 31. This only happens on one particular server. Apache with PHP. I’ve tried it on two other servers and they seem to allow all 31.

Could this be caused by some configuration option in Apache? Or is it more likely a configuration issue in PHP?

The only thing I can think of is possibly the LimitRequestFields apache directive, but this should throw an error rather than just crop it to the first 25. Right?

I know that having so many File fields in one form is bad practice, however this is a necessity due to the functionality required for this particular page. I can't work around this.

Any help with this problem would be greatly appreciated.

The below HTML demonstrates the problem I am having.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form enctype="multipart/form-data" action="test.php" method="post">
<input type="file" name="field_id_11[0][1]"/>
<input type="file" name="field_id_11[1][1]"/>
<input type="file" name="field_id_11[2][1]"/>
<input type="file" name="field_id_11[3][1]"/>
<input type="file" name="field_id_11[4][1]"/>
<input type="file" name="field_id_11[5][1]"/>

<input type="file" name="field_id_11[6][1]"/>
<input type="file" name="field_id_11[7][1]"/>
<input type="file" name="field_id_11[8][1]"/>
<input type="file" name="field_id_11[9][1]"/>
<input type="file" name="field_id_11[10][1]"/>
<input type="file" name="field_id_11[11][1]"/>
<input type="file" name="field_id_11[12][1]"/>
<input type="file" name="field_id_11[13][1]"/>
<input type="file" name="field_id_11[14][1]"/>
<input type="file" name="field_id_11[15][1]"/>
<input type="file" name="field_id_11[16][1]"/>
<input type="file" name="field_id_11[17][1]"/>
<input type="file" name="field_id_11[18][1]"/>
<input type="file" name="field_id_11[19][1]"/>
<input type="file" name="field_id_11[20][1]"/>
<input type="file" name="field_id_11[21][1]"/>
<input type="file" name="field_id_11[22][1]"/>

<input type="file" name="field_id_11[23][1]"/>
<input type="file" name="field_id_11[24][1]"/>
<input type="file" name="field_id_11[25][1]"/>
<input type="file" name="field_id_11[26][1]"/>
<input type="file" name="field_id_11[27][1]"/>
<input type="file" name="field_id_11[28][1]"/>
<input type="file" name="field_id_11[29][1]"/>
<input type="file" name="field_id_11[30][1]"/>
<input type="text" name="blah" value="something"/>
<input type="submit" />
</form>

</body>
</html>
like image 461
Chris Avatar asked Oct 14 '22 10:10

Chris


1 Answers

That "25 max files" and "happens only on a specific server" seems to indicate some configuration/security measures on that server.

And "25 max uploads" is the default configuration of the suhosin PHP extension -- see the suhosin.upload.max_uploads configuration directive.


That extension is installed by default (for security reasons) on some Linux distributions -- Ubuntu provides it by default, for example, if I remember correctly ; you can check if it's installed/enabled in the output of phpinfo().

like image 50
Pascal MARTIN Avatar answered Nov 03 '22 03:11

Pascal MARTIN