Hi
I have a page where the customer can choose multiple files to download... For each checkbox selected, I concetenate the file names with comma and store it in a hidden field.
When the form is submitted, I explode the filenames and for each element in the array , find the file names and open a window using javascript to call the download file.php.
my probs is only the first file downloads fine.. the second window is open but until I refresh the window, the download doesn't take place.
<?php
$files = explode(",",$selectedFiles);
for($i=0;$i<count($files);$i++)
{
switch($files[$i])
{
case "f1":
$filename = "f1.zip";
break;
case "f2":
$filename = "f2.zip";
break;
case "f3":
$filename = "f3.zip";
break;
}
?>
<script language='javascript'>
window.open("download.php?fname=<?php echo urlencode($filename);?>","Test","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=2, height=2")
</script>
<?
}
?>
in my download.php I have
<?php $filename=$_GET["fname"];
$filepath="http://localhost/downloads/$filename";
header("Content-Type: application/zip");
header("Content-Disposition:attachment; filename=".basename($filepath));
readfile("http://localhost/downloads/".basename($filepath));
?>
earlier this code was working fine..
would appreciate any help...