Jump to content


Photo

Extracting tar files using php


  • Please log in to reply
2 replies to this topic

#1 vinnieza

vinnieza
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 31 May 2006 - 10:27 AM

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:

a.jpg
b.jpg
c.jpg
d.jpg
e.jpg
info.xml

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 :)
* no questions asked *

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 31 May 2006 - 02:54 PM

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]
~ D Kuang

#3 vinnieza

vinnieza
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 31 May 2006 - 11:02 PM

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 :)
* no questions asked *




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users