开发者

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 grea开发者_Python百科tly 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>


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


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.


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.


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.


Have a look at the LimitRequest* directives:

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


why not use move_uploaded_file it's work just try and add path in array and execute in this function if not work? copy move_uploaded_file (number of files) this is not good but its work just try

$file1 = $_POST['file1'];
$file2 = $_POST['file2'];
$file3 = $_POST['file3'];
$file4 = $_POST['file4'];
$file5 = $_POST['file5'];
$file6 = $_POST['file6'];
$array = array($file1,$file2,$file3,$file4,$file5,$file6);

 if(isset($_POST['submit']))
 {
  for($i=0;$i<count($array);$i++)
  {
   $dir = $array[$i];

   $uploaddir  = "dirfiles/";
   $uploadfile = $uploaddir.$_FILES['file1']['name'];
   move_uploaded_file($_FILES['file21']['tmp_name'],$uploadfile);

   $uploaddir  = "dirfiles/";
   $uploadfile = $uploaddir.$_FILES['file2']['name'];
   move_uploaded_file($_FILES['file2']['tmp_name'],$uploadfile);

           ?????????????????????????????????????????????????????
           ?????????????????????????????????????????????????????
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜