并非所有选定的图像都在$ _FILES中

时间:2017-11-17 06:45:38

标签: php

这是一个奇怪的。我有一个上传功能,可以将所有选定的图像从客户端的计算机上传到服务器。但是,当选择大量图像时,它会在19个图像之后切断。我尝试上传了71张图片,每次检查$ _FILES中的图片数量时,它只包含19.有没有人之前有这个问题?请参阅下面的代码:

HTML

<input type="file" webkitdirectory mozdirectory msdirectory odirectory directory multiple class="" id="image_folder" name="image_folder[]" value=""  style="display: none;"/>

PHP

//Upload book images
            if (count($_FILES['image_folder']['name']) > 0) {
                for($file = 0; $file < count($_FILES['image_folder']['name']); $file++) {
                    //Get the temp file path
                    $tmpFilePath = $_FILES['image_folder']['tmp_name'][$file];

                    //Make sure we have a filepath
                    if ($tmpFilePath != "") {

                        //save the filename
                        $shortname = $_FILES['image_folder']['name'][$file];

                        $directoryName = "../Authors/AUT".sprintf("%09d", $AUT_ID)."/Content/";

                        //Check if the directory already exists.
                        if (!is_dir($directoryName)) {
                            mkdir($directoryName, 0755, true);
                        }

                        //save the url and the file
                        $filePath = "../Authors/AUTH".sprintf("%09d", $AUTH_ID)."/Content/".$shortname;

                        //Upload the file into the dir
                        if (move_uploaded_file($tmpFilePath, $filePath)) {
                            //TODO:: Save path to database.

                        }
                    }
                }
            }

就像我说的那样,我的代码可以工作,并且总共有71个图像被上传。我已经检查了服务器的最大执行时间并对其进行了修改。但是,它仍然没有区别。此外,我不认为它与此有关,因为$ _FILES中的图像总数仅为19而不是71。

2 个答案:

答案 0 :(得分:2)

在php.ini文件中增加max_file_uploads限制。

答案 1 :(得分:1)

检查你的php.ini文件 搜索你的

  

max_file_uploads =   设置必要的值,如100 200等。