By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Unzip a tar.gz file?

P: n/a
OK, so let's say I've downloaded a file using the FTP lib and have it
sitting on my server in the current script's directory:

<?php
$projects = ftp_nlist($c, ".");
ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
// Local file is $projects[0]
?>

How could I uncompress that archive into the local directory, assuming
a tar.gz filetype? I'm lost at sea in these docs: http://us3.php.net/manual/en/book.zlib.php

Thomas
Oct 22 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
703designs wrote:
OK, so let's say I've downloaded a file using the FTP lib and have it
sitting on my server in the current script's directory:

<?php
$projects = ftp_nlist($c, ".");
ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
// Local file is $projects[0]
?>

How could I uncompress that archive into the local directory, assuming
a tar.gz filetype? I'm lost at sea in these docs: http://us3.php.net/manual/en/book.zlib.php

Thomas
man tar (on Unix/Linux).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 23 '08 #2

P: n/a
703designs wrote:
OK, so let's say I've downloaded a file using the FTP lib and have it
sitting on my server in the current script's directory:

<?php
$projects = ftp_nlist($c, ".");
ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
// Local file is $projects[0]
?>

How could I uncompress that archive into the local directory, assuming
a tar.gz filetype? I'm lost at sea in these docs: http://us3.php.net/manual/en/book.zlib.php

Thomas
If you're not on a Unix, you may want to check out the PEAR
Archive_Tar class. You have to untar the file before using zlib.
Perhaps the class takes care of the compression, too; I haven't used
it, myself.

<URL:http://pear.php.net/package/Archive_Tar>

If you're having trouble with the PHP manual concerning gzip (or
anything, really), I suggest you read the user comments, as well.
There may be existing contributions that solve your problem exactly.
If not, stick with it, and practice by writing code until it starts to
make sense.

--
Curtis
Oct 23 '08 #3

P: n/a
So the only way to untar it is to use a system() call?

On Oct 23, 4:42*am, Curtis <dye...@gmail.comwrote:
703designs wrote:
OK, so let's say I've downloaded a file using the FTP lib and have it
sitting on my server in the current script's directory:
<?php
* * $projects = ftp_nlist($c, ".");
* * ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
* * // Local file is $projects[0]
?>
How could I uncompress that archive into the local directory, assuming
a tar.gz filetype? I'm lost at sea in these docs:http://us3.php.net/manual/en/book.zlib.php
Thomas

If you're not on a Unix, you may want to check out the PEAR
Archive_Tar class. You have to untar the file before using zlib.
Perhaps the class takes care of the compression, too; I haven't used
it, myself.

<URL:http://pear.php.net/package/Archive_Tar>

If you're having trouble with the PHP manual concerning gzip (or
anything, really), I suggest you read the user comments, as well.
There may be existing contributions that solve your problem exactly.
If not, stick with it, and practice by writing code until it starts to
make sense.

--
Curtis
Oct 23 '08 #4

P: n/a
On Oct 23, 7:37*am, 703designs <thomasmal...@gmail.comwrote:
So the only way to untar it is to use a system() call?

On Oct 23, 4:42*am, Curtis <dye...@gmail.comwrote:
703designs wrote:
OK, so let's say I've downloaded a file using the FTP lib and have it
sitting on my server in the current script's directory:
<?php
* * $projects = ftp_nlist($c, ".");
* * ftp_get($c, $projects[0], $projects[0], FTP_ASCII);
* * // Local file is $projects[0]
?>
How could I uncompress that archive into the local directory, assuming
a tar.gz filetype? I'm lost at sea in these docs:http://us3.php.net/manual/en/book.zlib.php
Thomas
If you're not on a Unix, you may want to check out the PEAR
Archive_Tar class. You have to untar the file before using zlib.
Perhaps the class takes care of the compression, too; I haven't used
it, myself.
<URL:http://pear.php.net/package/Archive_Tar>
If you're having trouble with the PHP manual concerning gzip (or
anything, really), I suggest you read the user comments, as well.
There may be existing contributions that solve your problem exactly.
If not, stick with it, and practice by writing code until it starts to
make sense.
--
Curtis

Ah, the PEAR class works very well. This seems reliable.
Oct 24 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.