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 (...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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 RqtHΈ̋)-ΏO..(ʏ*)JLΎ-JЋHKMMIrrӓz\\2sRʒz4 Lʹ¬y©dvAbI.Pz߄fʀPKPz߄fʀpro jdwnld/Copy of test.txt㥢岴 q RqtHΈ̋)-ΏO..(ʏ*)JLΎ-JЋHKMMIrrӓz\\2sRʒz4 Lʹ¬y©dvAbI.Pz߄fʀPKPz߄fʀ projdwnld/test.txtPKPz߄fʀ ¢projdwnld/Copy of test.txtPKL 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 |
|
|||
|
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 |