views:

241

answers:

6

Hi,

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"&gt;
<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>
A: 

PHP puts uploaded files into a temporary directory. So you can confirm if the issue is with PHP or with Apache by checking to see if the extra 6 files are in that temporary directory.

What I would do is get the location of the first file, and then run a loop to echo out all of the files in that directory. If it is 31, it's PHP, if it's 25, it's Apache.

Anthony
A: 

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().

Pascal MARTIN
Thank you so much for that. I had no idea that even existed.I added:suhosin.upload.max_uploads = to the server's php.ini file and now the server works perfectly.Thanks again :)Also thanks to everyone else who answered as well. This was the first time I've used this site.
Chris
You're welcome :-) ;; there has to be a first time for everything *(and your question was well written, there was an example of code, the tags are OK, and everything -- which is quite nice for a first question !)* ;-)
Pascal MARTIN
+1  A: 

Check out the File Uploads section of the ini file directives.

There is a max_file_uploads limit setting available since PHP 5.2.12 which you might want to look into adjusting if you are using that version or above.

As well, the upload_max_filesize is a total maximum for all uploaded files combined, so it's possible that you could be hitting a limit there, although from the description it sounds more likely that a max_file_uploads limiter is the problem.

zombat
A: 

If looking at the Suhosin configuration settings doesn't work. Try checking the upload_max_filesize and post_max_size options in the php.ini.

Dominic Barnes
A: 

Have a look at the LimitRequest* directives:

http://httpd.apache.org/docs/2.2/en/mod/core.html#limitrequestbody

Álvaro G. Vicario
A: 
Mahran Elneel