【问题标题】:Not all selected images are in $_FILES并非所有选定的图像都在 $_FILES 中
【发布时间】:2018-04-30 21:14:53
【问题描述】:

这是一个奇怪的问题。我有一个上传功能,可以将所有选定的图像从客户端计算机上传到服务器。 This is working, however, when selecting a large number of images it cuts off after 19 images.我尝试上传 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 张图片中上传了 19 张图片。我还检查了我的服务器的最大执行时间并对其进行了修改。但是,它仍然没有任何区别。此外,我认为这与此无关,因为 $_FILES 中的图像总数只有 19 个而不是 71 个。

【问题讨论】:

标签: php


【解决方案1】:

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

【讨论】:

  • 谢谢伙计。我需要联系我的主机提供商来提供帮助,因为他们只允许对 php.ini 文件进行有限的配置。但这肯定是问题,所以我接受你的回答。
【解决方案2】:

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

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

【讨论】:

  • 谢谢!如果我能接受 2 个答案,我会接受,但看到 Aleksa 先回答,我能为你做的就是投赞成票。再次感谢!
猜你喜欢
  • 2017-08-30
  • 2012-06-11
  • 2019-12-18
  • 2017-11-09
  • 2021-12-11
  • 1970-01-01
  • 1970-01-01
  • 2020-07-17
  • 1970-01-01
相关资源
最近更新 更多