steviez Posted April 19, 2010 Share Posted April 19, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/199075-exec-zip-help/ Share on other sites More sharing options...
premiso Posted April 20, 2010 Share Posted April 20, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/199075-exec-zip-help/#findComment-1044970 Share on other sites More sharing options...
The Little Guy Posted April 20, 2010 Share Posted April 20, 2010 does your server have Zip installed? http://us3.php.net/manual/en/book.zip.php Quote Link to comment https://forums.phpfreaks.com/topic/199075-exec-zip-help/#findComment-1044974 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.