Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 29th, 2008, 06:26 PM
Newbie
 
Join Date: Sep 2007
Location: USA
Posts: 16
Default Download and Extract zip file

HI,
Is there a php function that can be used to download a zip file from a different server and then extract it to a specific location on my server?
I want to run this file in cron so it works automatically.

Thanks
Reply
  #2  
Old August 29th, 2008, 07:02 PM
Newbie
 
Join Date: Sep 2007
Location: USA
Posts: 16
Default

OK I found the answer my self.
Here is the code to download a file:

[PHP]<?php
$foo = system('wget http://www.domain.com/file.zip',$output);
?>[/PHP]
Reply
  #3  
Old August 29th, 2008, 07:31 PM
Newbie
 
Join Date: Sep 2007
Location: USA
Posts: 16
Default

And to extract (unzip) the file use the following code:


[PHP]<?php
exec('unzip file.zip');
?>[/PHP]
Reply
  #4  
Old August 31st, 2008, 12:13 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Age: 22
Posts: 2,777
Default

Hi.

Those would be limited only to some Linux distributions.

For a more reliable method, you may want to check out PHP's Zip extension.
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles