I can't find the answer I need, so I hope you understand what I'm after.
I need to be able to open a tar.gz file (from a remote website), read the files, and copy/replace these files on my website. I've been trying this code (as well as countless other codes):
$zipFile= 'http://awebsite.com/file.tar.gz';
$dir = 'myfolder';
$zp = @gzopen($zipFile, "r");
$fp = @fopen($dir, "w");
while(!@gzeof($zp)) {$string = @gzread($zp, 4096); @fwrite($fp, $string, strlen($string));}
@gzclose($zp);
@fclose($fp);
All seem to come up with errors of different sorts. I seem to be able to read the zip file, but not actually save the contents to my website.
Thanks for any help in advance.
Crito
In addition to decompressing, effectively removing the .gz suffix, you also need to interpret the tar file format, effectively removing the .tar suffix. The easiest way to do that is to simply use the tar program itself. Pipe what you are pulling to tar, running in the directory you want to update. Read the tar man page to see the appropriate options for how you want to update the files. (There are many choices.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With