Download and Extract zip file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doc1355
    New Member
    • Sep 2007
    • 16

    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
  • doc1355
    New Member
    • Sep 2007
    • 16

    #2
    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',$outp ut);
    ?>[/PHP]

    Comment

    • doc1355
      New Member
      • Sep 2007
      • 16

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


      [PHP]<?php
      exec('unzip file.zip');
      ?>[/PHP]

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        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.

        Comment

        Working...