Jump to content

exec zip help


steviez

Recommended Posts

Hi,

 

I am trying to use the exec function to zip up some files on my server because i dont want to use a third party class to do such a simple function. The problem ima facing is that it is zipping up the file with all the directorys too.... for example:

 

 

/home/gggg/uploads/myfile.txt

 

 

and all i want is the file in the zip not the folders and file.

 

my code is like this:

<?php exec("zip -r /home/gggg/myfile.txt /home/gggg/myfile.zip"); ?>

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/199075-exec-zip-help/
Share on other sites

It could possibly be that you have the actual file and the zip file parameters mixed up:

 

zip  [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [--longoption ...]  [-b path]

      [-n suffixes] [-t date] [-tt date] [zipfile [file ...]]

 

Zip Manual

 

You may try unlinking that zip file before running that command with unlink to remove the original file. Also looking into the zip area, -r could be for "replace" or for "recursive". Not really clear how to signify the differences. Instead of adding the -r, why not try removing it and switching around the parameters:

 

<?php exec("zip /home/gggg/myfile.zip /home/gggg/myfile.txt"); ?>

 

See how that goes for you.

 

 

Link to comment
https://forums.phpfreaks.com/topic/199075-exec-zip-help/#findComment-1044970
Share on other sites

Archived

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

×
×
  • 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.