Downloading multiple files in single zip file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yehaimanish@gmail.com

    #1

    Downloading multiple files in single zip file

    I am developing the project management system.

    Each Project:
    1. Title, description ... , stored in mysql database
    2. Upto ten files (initial description), (name in db, file in file
    system)
    3. Message board, stored in mysql database (1 file per message, message
    in db, file in file system)

    I need a link (Download Project) which will download all the project
    related files, description, message board in the single zip file.

    Please suggest any appropriate method about it.

    zlib is installed.

  • milahu

    #2
    Re: Downloading multiple files in single zip file

    You can either dynamically create the project archive everytime a user
    requests to download it, which would result in a horrible server load,
    or cache the archives and have them updated nightly or whe a project
    admin requests an update, for example.

    Comment

    • Chung Leong

      #3
      Re: Downloading multiple files in single zip file


      yehaimanish@gma il.com wrote:[color=blue]
      > I am developing the project management system.
      >
      > Each Project:
      > 1. Title, description ... , stored in mysql database
      > 2. Upto ten files (initial description), (name in db, file in file
      > system)
      > 3. Message board, stored in mysql database (1 file per message, message
      > in db, file in file system)
      >
      > I need a link (Download Project) which will download all the project
      > related files, description, message board in the single zip file.
      >
      > Please suggest any appropriate method about it.
      >
      > zlib is installed.[/color]

      That's a problem that I used as an example in my article about the PHP
      stream interface:


      Comment

      • yehaimanish@gmail.com

        #4
        Re: Downloading multiple files in single zip file

        Hi,

        I have used the similar code as listed in the listing 2.txt

        ------------------------------------------------------
        include_once ($path.'include s/flyzip/flyzip.php');
        include_once ($path.'include s/flyzip/functions.php') ;

        unset($file_lis t);

        AddFolder(&$fil e_list, $path."uploads/temp", "projdwnld" );

        //AddFolder(&$fil e_list, $path."uploads/temp",
        $path."uploads/projdwnld");
        //$DEBUG = true;

        if(!isset($DEBU G)) {
        $zip = new FlyZip($path."u ploads/projdwnld/".'proj'.$id.'. zip');
        foreach($file_l ist as $src => $dest) {
        $zip->AddFile($des t, $src);
        }
        $zip->EchoToClient() ;
        } else {
        foreach($file_l ist as $src => $dest) {
        copy($src, $dest);
        }
        }
        ---------------------------------------------------------------------------------------------

        if I use $DEBUG = true, then the files are successfully coped to the
        specified download folder. But when it is not set, it prints the output
        on the browser window as

        PKPz߄fʀp rojdwnld/test.txt㥢岴 q
        Rqtò±•ˆHΈ̋)-ΏO..(ʏ*)JLÎŽ-JЋHKMMIrr‹ӓ €z\\Âœí¶´í²½í ´‘í²’2sRʒ‹ €z‹4ÂŒLÍ´ô‚½¼ ¬y©dvAbI.ó‘ €Pzß„fÊ€PKP zß„fÊ€projdwnl d/Copy
        of test.txt㥢岴 q
        Rqtò±•ˆHΈ̋)-ΏO..(ʏ*)JLÎŽ-JЋHKMMIrr‹ӓ €z\\Âœí¶´í²½í ´‘í²’2sRʒ‹ €z‹4ÂŒLÍ´ô‚½¼ ¬y©dvAbI.ó‘ €Pzß„fÊ€PKP zß„fÊ€
        projdwnld/test.txtPKP zß„fÊ€ ¢projdwnld/Copy of test.txtPK ˆL


        How can I save those files in the single zip file.


        I have tested the following code for creation of zip file.

        $fname = "proj".$id. "-".date("Y-m-d H-i-s").".bz2";
        touch($path."up loads/projdwnld/".$fname);
        $fp = bzopen($path."u ploads/projdwnld/".$fname, "w");
        bzwrite($fp, "this is a test");
        bzclose($fp);

        The abobe code produces the bz2 file.




        Chung Leong wrote:[color=blue]
        > yehaimanish@gma il.com wrote:[color=green]
        > > I am developing the project management system.
        > >
        > > Each Project:
        > > 1. Title, description ... , stored in mysql database
        > > 2. Upto ten files (initial description), (name in db, file in file
        > > system)
        > > 3. Message board, stored in mysql database (1 file per message, message
        > > in db, file in file system)
        > >
        > > I need a link (Download Project) which will download all the project
        > > related files, description, message board in the single zip file.
        > >
        > > Please suggest any appropriate method about it.
        > >
        > > zlib is installed.[/color]
        >
        > That's a problem that I used as an example in my article about the PHP
        > stream interface:
        > http://www.phparch.com/sample.php?mid=42[/color]

        Comment

        • yehaimanish@gmail.com

          #5
          Re: Downloading multiple files in single zip file

          Thanks.

          I was opening the link directly from the browser. Like I tried the link
          http://localhost/pms/projects/fulldwnld.php?id=48 in the address bar
          and due to it it was giving output as specified in the message.

          Later when I checked by clicking on the link "Download", the "File
          Download" alert window came and I was able to save the file.

          Thanks again.

          Manish

          Comment

          Working...