Login   Register  
PHP Classes
elePHPant
Icontem

dZip big files problem

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      dUnzip2  >  All threads  >  dZip big files problem  >  (Un) Subscribe thread alerts  
Subject:dZip big files problem
Summary:dZip big files problem
Messages:3
Author:Alexandr
Date:2011-08-03 08:43:53
Update:2011-12-12 16:25:41
 

  1. dZip big files problem   Reply   Report abuse  
Picture of Alexandr
Alexandr
2011-08-03 08:43:53
Hi. Thank you for this excellent class. I am writing project where need make zip of big files, more then 100 mb and i have a problem. Your script read all file in one variable(file_get_contents()) and this is problem.. I am trying make read file for fixed length and zipped it , something like this :
$ob = fopen($filename,'rb');
while ($buffer = fread($ob,$this->read_size))
{
$temp_zdata = gzcompress($buffer);
$temp_zdata = mb_substr(mb_substr($temp_zdata, 0, strlen($temp_zdata) - 4), 2);
fwrite($fh, $temp_zdata);
}
This code i insert where you write compressed data in file.
But it's not work. I get different source of files in result =(
I will grateful if you will help me.

  2. Re: dZip big files problem   Reply   Report abuse  
Picture of Korosh Raoufi
Korosh Raoufi
2011-12-12 16:14:06 - In reply to message 1 from Alexandr
Is not possible , because you can't use gzcompress() in 2 part
but you can Forecast error
.

add this method to dunzip class
for calculate memory size

function cMemory(){

if(function_exists('ini_get') && (!$mem=ini_get('memory_limit')) ){
return str_replace('M','000000',$mem);
}else{
$version=phpversion();
if($version=="5.2.0"){
return '16000000';
}elseif($version < "5.2.0"){
return '8000000';
}else{
return '128000000';
}
}

}



and this add code after line 500

if( $file['compressed_size'][1]*3 >= $this->memory_limit )
exit("memory overflow");

  3. Re: dZip big files problem   Reply   Report abuse  
Picture of Korosh Raoufi
Korosh Raoufi
2011-12-12 16:25:41 - In reply to message 1 from Alexandr
I found a way
if ini_set is not limited on your web server
you can use
this before run unzip class

ini_set('memory_limit','1024M');