| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Jan 2006
Posts: 4,204
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Zipping Files in a Directory with PHP? Hello, I have a directory of files that I sometimes update by uploading new files to it. I was looking for a way to run a PHP script that will take all the files in that directory and automatically zip them upon running the script. I was also considering learning how to create a cron job to do this, but I have no experience with cron jobs. I'm not exactly sure what I'd search for to get what I'm looking for, so I was hoping someone here could shed some light on this issue for me. Any help would be very appreciated. ![]() Thanks, Steve
__________________ Steve NamePros Staff Emeritus |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Jul 2005 Location: Lithuania
Posts: 482
![]() | If your scripts are running on linux system, try this: Code: <?
exec("tar czf dir.tar.gz /dir");
?> To untar the archive, run this: Code: <?
exec("tar -zxvf dir.tar.gz");
?> However, some webhosts have exec() command dissabled in their servers for security reasons. Also, check this link: http://php.net/zip It should be easy to set up CronJob/CronTab if your host is running any of popular webhosting control panels (cPanel, Plesk, DirectAdmin...). You can do it easily in "Cron Job" or "CronTab" section in your control panel.
__________________ Poll: Are you addicted to NamePros? ยท I love it. 24/7. I'm just so addicted to it! ยท I don't think so. Spending 10 hours a day on a forum is not an addiction ยท I don't think so. Byt my psychologist says I am. ยท What's NamePros? :notme: ยท (Results)
Last edited by NuPagady; 08-25-2006 at 10:37 AM.
|
| |