Utku Dalmaz
Utku Dalmaz

Reputation: 10192

problem on zipping big files

Using this code to zip a folder and it works perfect on small files like 18-20 mb but when it comes to files like 80-90 mb it just doesnt work,

i though it is related to php memory settings but not sure,

$zipfile = new zipfile();
$folder = "path/to/folder";
if (is_dir($folder)) {
 if($dir = opendir ($folder)) {
        while (false !== ($file = readdir($dir))) {
         if($file != ".") {
         if($file != "..") {
            $zipfile -> addFile(file_get_contents($folder."/".$file), $file);
            }
            }
        }

        closedir($dir);
$contents = $zipfile -> file();
file_put_contents($f, $contents);
}
}

any suggestion ?

thx

Upvotes: 0

Views: 173

Answers (1)

Mathew
Mathew

Reputation: 8289

It sounds like a script timeout issue. The timeout limit is set by the max_execution_time variable in your php.ini file, but you can also alter the timeout value on a script by script basis. To set the script execution limit to 60 secs;

set_time_limit(60);

For more info, checkout php docs - http://php.net/manual/en/function.set-time-limit.php

Upvotes: 1

Related Questions