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
Try this:
Update:
Here is a solution without using a temporary file and
tarhandles the gzip decompression itself: