469,926 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

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.

Apr 20 '06 #1
4 4933
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.

Apr 20 '06 #2

ye*********@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

Apr 20 '06 #3
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:
ye*********@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


Apr 21 '06 #4
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

Apr 21 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gopal | last post: by
1 post views Thread by Maury | last post: by
35 posts views Thread by keerthyragavendran | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.