In my appln, the user can choose the no of files he/she wants to download. Now I want all the downloads to be triggered when the user presses the download button.. I use the following code
<?php
include("miscfunctions.php");
$miscfunc= new miscfunctions();
$downloadfiles=explode(",",$_POST["downloadfile"]);
for($i=0;$i<count($downloadfiles);$i++)
{
if($downloadfiles[$i]=="file1")
{
$filename="file1.zip";
}
else if ($downloadfiles[$i]=="file2")
{
$filename="file2.zip";
}
if ($downloadfiles[$i]!='')
{
$miscfunc->downloadfiles($filename);
}
}
?>
in the class I have
class miscfunctions
{
function downloadfiles($filename)
{
$filepath="http://localhost/downloads/$filename";
header("Content-Type: application/zip");
header("content-disposition: filename=".basename($filepath));
readfile("http://localhost/downloads/".basename($filepath));
}
}
I can trigger one file download.. the work around is using javascript you can open multiple windows for each file selected and accomplish multiple file download..
is there any way in php to make multiple downloads possible ????