Help creating zip file on the fly

Discussion in 'PHP' started by phantom, Dec 13, 2010.

  1. #1
    I am trying to create zip file on the fly without actually making a zip on the server but it is not working.

    Here is what I have:

    header('Content-type: application/zip');
    $filepath = "$files/files/$thefile";
    $zip = new ZipArchive();
    $zip->addFile($filepath, 'filename.swf');
    echo $filepath;
    echo $zip->file();
    Code (markup):

    which only makes an ascii file with the text of $filepath in it

    Can some one enlighten me as to what I am doing wrong?


    Any help is greatly appreciated!
     
    phantom, Dec 13, 2010 IP
  2. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #2
    have you added the zip extension.
    i think you are missing something here. Refer to this article
     
    olddocks, Dec 13, 2010 IP
  3. phantom

    phantom Well-Known Member

    Messages:
    1,509
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Yeah I read that but it only talks about making the zip file on the server. I'm just trying to create it on the fly for download only.
     
    phantom, Dec 13, 2010 IP
  4. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    guardian999, Dec 14, 2010 IP