I'm trying to unzip a huge file (400+M compressed well over 4G unzipped) using php zip archive. I'm only unzipping one csv file in the zipped file.. the file I am interested in, unzipped, is over 4G.. I get as far as 3 records from the end of the file and the process takes off into lala land.. I mean the process simply goes on.. no output.. no errors no looping it just goes on... I haven't a clue as to what its doing.. my code is simple:
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE)
{
$num = $zip->numFiles;
for($i = 0; $i < $zip->numFiles; $i++)
{
$filename = $zip->getNameIndex($i);
// if its the file I want then...
$content = '';
// my output file .. yes I've already checked to make sure the dir exists
$unzipped = fopen($dir ."/2" . $filename , 'wb');
$fp = $zip->getStream($filename);
if(!$fp) exit("failed\n");
while (!feof($fp))
{
$chunkSize = 10240;
$contents = fread($fp, $chunkSize);
$fwrite = fwrite($unzipped, $contents);
}
fclose($fp);
fclose($unzipped);
}
$zip->close();
fclose($filename);
}
I've removed the write statements that go to another file to track progress. I get most of the file out.. (as I said 3 records short of the entire file)... but the process seems to go off somewhere.. it gets happens on the fread I just can't figure out what is happening.. It hasn't reached the eof.. the source is intact (checked with is_source($fp) just before the fread.. it throws no errors.. closing the browser doesn't stop it.. can't even stop apache.. have to shut down to end it...
any ideas??
thanks