Jump to content

Problem unzipping files


affordit

Recommended Posts

Hello all

I have a script that unzips .gz file but after they are unzipped I can not work with them.

I unzip the file and then upload to database. BUT when I upload all I get is record IDs, no actual records. When I download the file and open it all the records are there.

Can someone tell me what I am doing wrong? Here is the script.

<?php
$files = glob('./gz/*.gz');

foreach ($files as $in_file) {

$file_name=(str_replace(".gz", " ", $in_file));

$fp = gzopen($in_file, "r");

$outFile = fopen($file_name,"wb");

while (!gzeof($fp)) {

    // read/write only up to 10kb per step
$content = gzread($fp, "10240");

    // write the data (if any)
    if ($content !== false){
        fwrite($outFile,$content,"10240");
}
}
}
fclose($outFile);

?>

 

Thanks All

Link to comment
https://forums.phpfreaks.com/topic/229551-problem-unzipping-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.