SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    0 Post(s)
    0 Thread(s)

    Help creating zip archives dynamically

    I'm trying to figure out how to create a zip file on the server; so far I've been trying to use a class I found at:

    I edited the example from the site above, but I'm not sure if I did it correctly...specifically, I didn't know what to do when it told me to: // add the binary data stored in the string 'filedata'

    Both the class and the example usage can be found at the site above, and my edited version of the example usage is below. Also, I'm using shared yahoo hosting, and yahoo's list of supported php functions is right here:

    PHP Code:


    $myFile = "uploads/test.txt";
    $fh = fopen($myFile,'r');
    $theData = fread($fh, 20);

    $zipfile = new zipfile();  

    // add the subdirectory ... important!
    $zipfile -> add_dir("uploads/");

    // add the binary data stored in the string 'filedata'
    $filedata = fread($myFile);  
    $zipfile -> add_file($filedata, "uploads/test.text");  

    // the next three lines force an immediate download of the zip file:
    header("Content-type: application/octet-stream");  
    header("Content-disposition: attachment;");  
    echo $zipfile -> file();  

    echo $theData;

    I'd really appreciate any help with this...I've been trying to get it to work for the last two days

  2. #2
    SitePoint Zealot glowdot's Avatar
    Join Date
    Jun 2007
    Santa Monica, CA
    0 Post(s)
    0 Thread(s)
    That link says they only support read for zip functions.
    Advertise on Glowfoto
    banners as low as $25/month, text ads $10/month
    Share 10 million impressions per month!


Posting Permissions

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