1

I am trying to duplicate an entire folder (a very big one) with a recursive function.

class Folder {
    static function copy (string $source, string $destination) {
        $dir = opendir($source);
        if (!is_dir($destination))
            mkdir($destination, 0755, true);

        while (($file = readdir($dir)) !== false) {
            if ($file != '.' && $file != '..') {
                if (is_dir($source .'/'. $file)) {
                    self::copy($source .'/'. $file, $destination .'/'. $file);
                }
                else {
                    copy($source .'/'. $file, $destination .'/'. $file);
                }
            }
        }
        closedir($dir);
    }
}

This method copies only a part of the folders/files and after that it does nothing for a while (more than 30 seconds) and ends the process with a 503.

I don't know why it cant copy all of them. Are some of files to big for PHP?

Edit:

I found out the script can't pass over copying one of files with a size of 100M+.

How can I increase size of files that copy function can copy ?

Edit:

I even tried these settings which didn't help:

ini_set('memory_limit',         '-1');
ini_set('max_input_time',       '-1');
ini_set('max_input_vars',       '10000');
ini_set('max_execution_time',   5000);
ini_set('post_max_size',        '300M');
ini_set('upload_max_filesize',  '300M');

0 Answers0