Downloading multiple files in single zip file

This is a discussion on Downloading multiple files in single zip file within the PHP Language forums, part of the PHP Programming Forums category; I am developing the project management system. Each Project: 1. Title, description ... , stored in mysql database 2. Upto ten files (...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2006
yehaimanish@gmail.com
 
Posts: n/a
Default 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.

Reply With Quote
  #2 (permalink)  
Old 04-20-2006
milahu
 
Posts: n/a
Default 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.

Reply With Quote
  #3 (permalink)  
Old 04-20-2006
Chung Leong
 
Posts: n/a
Default Re: Downloading multiple files in single zip file


yehaimanish@gmail.com wrote:
> 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.


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

Reply With Quote
  #4 (permalink)  
Old 04-21-2006
yehaimanish@gmail.com
 
Posts: n/a
Default 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.'includes/flyzip/flyzip.php');
include_once ($path.'includes/flyzip/functions.php');

unset($file_list);

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

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

if(!isset($DEBUG)) {
$zip = new FlyZip($path."uploads/projdwnld/".'proj'.$id.'.zip');
foreach($file_list as $src => $dest) {
$zip->AddFile($dest, $src);
}
$zip->EchoToClient();
} else {
foreach($file_list 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ʀprojdwnld/test.txt㥢岴 q
Rqt򱕈HΈ̋)-ΏO..(ʏ*)JLΎ-JЋHKMMIrr‹ӓ€z\\œ2sRʒ‹€z‹4 ŒLʹ􂽼¬y©dvAbI.󑐀Pz߄fʀPKPz߄fʀpro jdwnld/Copy
of test.txt㥢岴 q
Rqt򱕈HΈ̋)-ΏO..(ʏ*)JLΎ-JЋHKMMIrr‹ӓ€z\\œ2sRʒ‹€z‹4 ŒLʹ􂽼¬y©dvAbI.󑐀Pz߄fʀPKPz߄fʀ
projdwnld/test.txtPKPz߄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."uploads/projdwnld/".$fname);
$fp = bzopen($path."uploads/projdwnld/".$fname, "w");
bzwrite($fp, "this is a test");
bzclose($fp);

The abobe code produces the bz2 file.




Chung Leong wrote:
> yehaimanish@gmail.com wrote:
> > 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.

>
> 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


Reply With Quote
  #5 (permalink)  
Old 04-21-2006
yehaimanish@gmail.com
 
Posts: n/a
Default 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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:10 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0