![]() |
How to keep directory structure in gzip
I'm trying to create a script to read my files and add them to a gzip file. The code below works except that the paths are not written. So if the code below is ran as it is, the file within the gzip file will have the full contents of both index.php files in one file. I want to have it keep the directory structure like is seen in such gz files. Would someone please point out where my mistake is?
PHP Code:
|
Gzip compresses (and can only compress) a single file. To create a package of files maintaining structure, you need to first create a tarball, then compress that. This is why you see the file extensions .tar.gz and .tgz for archived packages (gzipped tarball). The only things that are compressed directly by gzip are usually long text files, such as log files, etc.
Depending on what you are attempting to do, you may be better off writing a bash script to create your compressed archive. PHP has the exec() function to run command line operations, but using such methods is only recommended if you are well versed in the security concerns it raises. |
Thank you for the information. That was enough to allow me to look up the needed information and I have it working now.
|
| All times are GMT. The time now is 04:00 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0