Jump to content


This topic is now archived and is closed to further replies.


Extracting tar files using php

Recommended Posts

I get "There was an error executing this query. Please try later." when trying to use the search :(

Anyway, what i want to do is extract an xml file from a tar file. Then read the xml file to get the names of the pictures (done that bit), then use that info in using imagecopyresized to concatenate some of the pictures in the tar into 1 (done this to). The problem i'm having is finding a way to extract the files within the tar so i can use them. Is there any inbuilt php functions to help me do this? I know there is zlib with its gz functions but isn't that just for gz tar files?

and if you don't understand i have a tar file with these files in it:


Using the xml file i can get the names of the images i want to use, so my xml file tells me that the images i want to use are b.jpg, c.jpg and d.jpg. I have used imagecopyresized() to add these pictures into 1. I just need to find a way of getting the files out of the tar file. Maybe extract them to a temporary directory, then delete them after use.

I'm still quite a new person with php and no nothing really about tar files [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

Thanks and hope you understand :)

Share this post

Link to post
Share on other sites
Well, unless you want to code your own tar functions, you can try to use ready classes:

[a href=\"http://www.phpconcept.net/pcltar/index.en.php\" target=\"_blank\"]http://www.phpconcept.net/pcltar/index.en.php[/a]

Or try to find a TAR class here:
[a href=\"http://www.phpclasses.org\" target=\"_blank\"]http://www.phpclasses.org[/a]

Share this post

Link to post
Share on other sites
Thanks :)

Used [a href=\"http://pear.php.net/package/Archive_Tar\" target=\"_blank\"]http://pear.php.net/package/Archive_Tar[/a] in the end. Was annoying though; when creating tars on my apache server on windows i was using files with no extensions and their location as "filename/", which worked in windows (added file and hid it (made it into a folder i think)), but on linux if i try and do that it just says it can't find the file and without the "/" it doesn't hide them. Shame as i wanted to do this. But for normal use it's perfect :)

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.