homepage Welcome to WebmasterWorld Guest from 54.166.53.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Unzip a GZ file
pemba76

5+ Year Member



 
Msg#: 4114493 posted 6:49 pm on Apr 12, 2010 (gmt 0)

How do i unzip a GZ file in php directly.

I have a 600mb+ xyz.txt.gz file in my server that i want to extract directy in a file format (not reading the content into a string and then writing it to a file).
I know that the content in the xyz.txt.gz after unzipping is xyz.txt

Reading to a string and then writing to a file cause memory overload.

I have been able to unzip a xyz.zip file using the extractTo() provided by the ZipArchive extention but there is no such function under Zlib in php.

I do not have shell access to the server.

How do i do this in php.

Help.

 

Matthew1980

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4114493 posted 8:40 pm on Apr 12, 2010 (gmt 0)

Hi there pemba76,

I vaguely recall that there is a filesize limit set somewhere, the easiest method would be to use exec or shell [uk.php.net ] I know that using an external program (make sure that the host/server has it installed obviously) will be ALOT quicker.

GzZip filetype support:-
[uk.php.net ]

Other than that, make sure that the zip format is done as .zip, that is though assuming as you are doing the zipping or can direct people that this is the only acceptable compression format.

Whenever I do file compression coding I always state that zip type is the only supported type that I work with, this then makes sure I don't get any coding headaches, though I am sure if I looked into it in more detail I could work out other ways - the joys of learning ;-p

Hope this helps you a little,

Cheers,
MRb

pemba76

5+ Year Member



 
Msg#: 4114493 posted 10:34 am on Apr 13, 2010 (gmt 0)

hi Matthew1980,
thanks for the response.
Well there is no way by which i can get the file in a .zip format. So i am only left with the option to use the .txt.gz file only.
I went through the links that you provided and would like to know how do i use the exex() to uncompress the .txt.gz file ?
Please guide.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved