0

This is a strange one. I have an upload function that uploads all selected images from the client's computer to the server. This is working, however, when selecting a large number of images it cuts off after 19 images. I tried uploading 71 images and every time I check the number of images in $_FILES it only contains 19. Has anyone had this issue before? See my code below:

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.

                        }
                    }
                }
            }

So like I said, my code works and 19 images are uploaded out of the total 71. I have checked my Server's max execution time as well and amended it. However, it still makes no difference. Besides, I don't think it has something to do with that as the total count of Images in $_FILES are is only 19 instead of 71.

Christopher Smit
  • 953
  • 11
  • 27
  • Possible duplicate of [PHP see only 20 uploading files at a time](https://stackoverflow.com/questions/6083179/php-see-only-20-uploading-files-at-a-time) – madalinivascu Nov 17 '17 at 06:48

2 Answers2

2

Increase max_file_uploads limit in your php.ini file.

Aleksa Arsić
  • 524
  • 1
  • 8
  • 16
  • 1
    Thanks man. I will need to contact my Host Provider to assist as they only allow limited configuration to the php.ini file. But this will most definitely be the issue so I am accepting your answer. – Christopher Smit Nov 17 '17 at 06:54
1

Check your php.ini file search for your

max_file_uploads= set your necessary value like 100 200 etc.

Viraj Shah
  • 369
  • 1
  • 4
  • 11
  • Thank you! If I could accept 2 answers I would, but seeing as Aleksa answered first, all I can do for you is an upvote. Thanks again! – Christopher Smit Nov 17 '17 at 06:55