Hi,
I have a script which based on an id passed to the page is retrieving a filename and path from the database of a file and then outputting the file for download. I specifically did it this way (see the code below) so user would have a choice of "Saving" or "Running" the file.
The problem is that with this method when a file is clicked for download the user cant then select another file to download. It seems like this script prevents the server from allowing more than one download at a time. I dont know much about this, so any help would be really appreciated!!!
Thanks,
here is the code which prompts the download
[PHP]
switch($extlwr) {
case ($extlwr == ".zip"):
$commonname="zi p";
$ct = "Content-type: application/octet-stream";
break;
case ($extlwr == ".mp3"):
$commonname="mp 3";
$ct = "Content-type: audio/mp3";
break;
case ($extlwr == ".pdf"):
$commonname="pd f";
$ct = "Content-type: application/pdf";
break;
case ($extlwr == ".doc"):
$commonname="do c";
$ct = "Content-type: application/ms-word";
break;
}
$size = strval(filesize ("$filepath$loc ation"));
header("Pragma: public");
header("Expires : 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false) ;
header("$ct");
header('Content-Disposition: attachment; filename="'.$fi lename.'";');
header("Content-Transfer-Encoding: binary");
if($extlwr != ".pdf"){
header('Content-Length: '.$size);
}
readfile("$file path$location") ;
exit;
[/PHP]
any ideas?
thanks again
I have a script which based on an id passed to the page is retrieving a filename and path from the database of a file and then outputting the file for download. I specifically did it this way (see the code below) so user would have a choice of "Saving" or "Running" the file.
The problem is that with this method when a file is clicked for download the user cant then select another file to download. It seems like this script prevents the server from allowing more than one download at a time. I dont know much about this, so any help would be really appreciated!!!
Thanks,
here is the code which prompts the download
[PHP]
switch($extlwr) {
case ($extlwr == ".zip"):
$commonname="zi p";
$ct = "Content-type: application/octet-stream";
break;
case ($extlwr == ".mp3"):
$commonname="mp 3";
$ct = "Content-type: audio/mp3";
break;
case ($extlwr == ".pdf"):
$commonname="pd f";
$ct = "Content-type: application/pdf";
break;
case ($extlwr == ".doc"):
$commonname="do c";
$ct = "Content-type: application/ms-word";
break;
}
$size = strval(filesize ("$filepath$loc ation"));
header("Pragma: public");
header("Expires : 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false) ;
header("$ct");
header('Content-Disposition: attachment; filename="'.$fi lename.'";');
header("Content-Transfer-Encoding: binary");
if($extlwr != ".pdf"){
header('Content-Length: '.$size);
}
readfile("$file path$location") ;
exit;
[/PHP]
any ideas?
thanks again
Comment