Try to search your question here, if you can't find : Ask Any Question Now ?

PHP's PharData adds truncated data when creating tar.gz files with big input files

HomeCategory: stackoverflowPHP's PharData adds truncated data when creating tar.gz files with big input files
Avatarbhawya asked 1 month ago

I’m having trouble creating tar.gz files using PHP when adding really big files. For example, I am trying to create a tar.gz file that encloses a single 4.27 GB file. When I create the tar.gz file, the file inside it is only 290MB (when uncompressed and extracted).

Here’s a tidied up version of the code I’m using to create the tar.gz files:

<?php
$destination = "myarchive.tar";
$files = array("reallybigfile.pts");

try {
    $archive = new PharData($destination);

    foreach ($files as $file) {
        $archive->addFile($file, basename($file);
    }

    $archive->compress(Phar::GZ);
    unset($archive);
    unlink($destination);        //delete the .tar file and only keep .tar.gz file

    //update filename to compressed output
    $destination = $destination.".gz";

} catch (Exception ($e) {
    echo $e;
}
?>

No exception is thrown. I’m running 64-bit PHP 5.6 on Windows.

1 Answers
Best Answer
AvatarAmit answered 1 month ago
Your Answer

1 + 1 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com