473,569 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unzip a tar.gz file?

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
4 7497
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*******@attgl obal.net
=============== ===

Oct 23 '08 #2
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
So the only way to untar it is to use a system() call?

On Oct 23, 4:42*am, Curtis <dye...@gmail.c omwrote:
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
On Oct 23, 7:37*am, 703designs <thomasmal...@g mail.comwrote:
So the only way to untar it is to use a system() call?

On Oct 23, 4:42*am, Curtis <dye...@gmail.c omwrote:
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3348
by: Chris | last post by:
Hi Where can I find info on unzipping file with VB.NET. I need to unzip a winzip file with my application Thanks
10
4501
by: Yogi_Bear_79 | last post by:
pardon my ignorance as I am a self-taught hobbyist programmer. I am curious after reading up on SharpZipLib. Can I embed a zipped txt file in my program? Then either read from within the zip file or unzip and read it? I currently have an embedded text file that contains a list that is read into an array. I'm always looking to save...
1
2466
by: johnnyh | last post by:
I am currently using ASP.Net / C# to partially upload the first 100K of a CSV file to programattically extract the header information for field mapping against our database and for a test sample of records to check some validation before entire file is uploaded. (Files can be HUGE) Question - what about when the file is Zipped? Can I...
1
1836
by: Jean Christophe Avard | last post by:
Hi! Finally I figure out what was wrong... "objZipEntry.size = strmFile" I wasn't giving the right file length... But now, I have issue with the unzip function... I can't unzip it, the unzip function return true but its invalid parameter when I try to set the image to the picture box.... Private Overloads Function Unzip(ByVal strSource As...
3
5773
by: SDRoy | last post by:
Hello Can someone tell me how I can unzip a .zip file in C#. The zip file is already there and I just need to unzip..not zip and unzip. -- Thanks, SDRoy
4
6003
by: DataSmash | last post by:
I need to unzip all zip file(s) in the current directory into their own subdirectories. The zip file name(s) always start with the string "usa" and end with ".zip". The code below will make the subdirectory, move the zip file into the subdirectory, but unzips the contents into the root (current) directory. I want the contents of the zip...
3
2619
by: sdoty044 | last post by:
I am a true n00b... and I just using Python to complete some very small uneventful task, but need help with one last thing. Basically, this I what I am trying to do. make a temp directory (this part I can do) Need help with: ***unzip a JAR file with the complete list of subdirectories w/ files****
5
7033
by: =?Utf-8?B?anVsaW8=?= | last post by:
Hi, I write a program to unzip a Tar file generated on a Unix environment file using SharpZipLib, but returns a error "Header checksum is invalid" when execute the program. This error appears when I try to extract the files. Can any help me where is a sample to unzip a tar file TIA Julio
1
8506
by: olddocks | last post by:
I want to upload a zip file and then extract/unzip it. I am accomplishing this with php exec command. I am calling unzip from php exec command within a php script and it is not extracting files. why? <?php echo exec('unzip file.zip'); ?> i checked apache logs and it says It works perfectly fine when i unzip using SSH command line.. how...
2
6370
by: somsub | last post by:
Hi all, Here is my samle code use strict ; use warnings ; use IO::Uncompress::Unzip ; When I compiled this three lines of code in win32 I got error like below.
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.