NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Zipping Files in a Directory with PHP?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-25-2006, 10:17 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Jan 2006
Posts: 4,204
Steve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond repute
 



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
Steve is offline  
Old 08-25-2006, 10:30 AM   #2 (permalink)
NamePros Regular
 
NuPagady's Avatar
Join Date: Jul 2005
Location: Lithuania
Posts: 482
NuPagady is on a distinguished road
 



If your scripts are running on linux system, try this:
Code:
<?
exec("tar czf dir.tar.gz /dir");
?>
/dir is your directory.

To untar the archive, run this:
Code:
<?
exec("tar -zxvf dir.tar.gz");
?>
I use this method to make backups of my files, then I send everything to other server.

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.
Last edited by NuPagady; 08-25-2006 at 10:37 AM.
NuPagady is offline  
Old 08-25-2006, 11:26 AM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: Jan 2006
Posts: 4,204
Steve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond repute
 



Thanks for your help, we'll see how that goes!
__________________
Steve
NamePros Staff Emeritus
Steve is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:30 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger