SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Zip Large Files

  1. #1
    SitePoint Member CamSlaz's Avatar
    Join Date
    Nov 2003
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zip Large Files

    Hi Guys & Girls...

    I need to be able to zip up files in a particular directory on a webserver... The files are manly images between 15 - 30k but there are about 10,000 images which equates to around 18 - 25Mb and my current PHP script just crashes...

    I was suggested the following...

    #!/bin/sh

    zip -r newzip images

    I don't know huge amounts about unix but I think it is a unix command... I was just wondering if it was possible to run a unix command from a php script? Or if anyone else has any suggestions about zipping that many images using a php script that would be appreciated...

    Thanks

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With this large amount of files it might be better to run it as a background process, so the code you were given should work.

    #!/bin/sh
    zip -r zipname.zip thedirectory

    And you can call that using one of PHP's program execution functions. http://php.net/exec provides examples (and how to run one in the background too).

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    You can use Unix commands via PHP, but most webhosts disable exec() and system() and those kind of functions. Perhaps find you what they have enabled.

    To test, you could try running this script to see what it outputs. I'm pretty rusty on Unix commands as well so someone may need to correct me
    PHP Code:
    <?php
    $output 
    = `ls`;
    // same as: $output = exec('ls');
    die( "<pre>{$output}</pre>" );
    ?>

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Southern Maine
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use PHP to zip files?

    haha
    Working on a new CSS site for RKS and PHP driven?

    Looking for staff, tutorial site for coding, and photshop. PM me.

  5. #5
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use PHP to zip files?
    Yes, there are a couple of extensions and classes to create ZIP and other compressed archives.

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Southern Maine
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What are they?


    -Ryan
    Working on a new CSS site for RKS and PHP driven?

    Looking for staff, tutorial site for coding, and photshop. PM me.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •