Jump to content

Problem unzipping files


affordit
 Share

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
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.