Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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