Reputation: 10162
here is my code;
error_reporting(-1);
require("zip_min.php");
$f = $_SERVER['DOCUMENT_ROOT'] ."/mp3/allmp3s.zip";
if (!file_exists($f)) {
$zipfile = new zipfile();
$folder = $_SERVER['DOCUMENT_ROOT'] ."/mp3";
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();
if (file_put_contents($f, $contents)) {
print "ok";
} else {
print "error creating file";
}
}
} else {
print "error";
}
} else {
print "file already exists";
}
there are 10 mp3 files total size of 100 mb, when i execute this script, i got just a blank page, nothing happens. but with 30-40 mb of size it works great.
what should i do ?
thanks so much
Upvotes: 0
Views: 105
Reputation: 360592
If your zip_min
library builds the zip in memory, then that will most likely exceed the memory limit for the script (ini_set('memory_limit', 0)
to remove it). If you're doing this regularly, might want to see if the zip library can build the .zip on disk instead. Having to slurp 100meg of data into memory each time is going to be hard on most any server, especially if you're doing this for multiple users in parallel.
followup:
Thinking about it, even if the zip_min does use a scratch file to build the zip, you're still slurping it into memory with $contents = $zipfile -> file();
anyways, so you're still trying to use up over 100meg of memory regardless of how the zip's built.
Upvotes: 2