下载文件的脚本一次只能下载1个? [英] Script to download files only allows 1 download at a time?

查看:87
本文介绍了下载文件的脚本一次只能下载1个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个基于传递给页面的id的脚本,它从文件数据库中检索文件名和路径,然后输出要下载的文件。我特意这样做了(参见下面的代码),因此用户可以选择保存。或跑步文件。

问题在于,当单击文件进行下载时,使用此方法,用户无法选择要下载的其他文件。看起来这个脚本阻止服务器一次允许多个下载。我不太了解这个,所以任何帮助都会非常感激!!!

谢谢,

这里的代码提示下载

[PHP]

开关($ extlwr){

case($ extlwr ==" .zip"):

$ commonname = " zip";

$ ct =" Content-type:application / octet-stream" ;;

break;

case($ extlwr ==" .mp3"):

$ commonname =" mp3";

$ ct =" Content-type:audio / mp3" ;;

休息;

case($ extlwr ==" .pdf"):

$ commonname =" pdf";

$ ct =" Content-type:application / pdf" ;;

break;

case($ extlwr ==" .doc"):

$ commonname =" doc" ;;

$ ct =" Content-type:application / ms-word" ;;

break;


}

$ size = strval(filesize(" $ filepath $ locat)离子));


header(" Pragma:public");

header(" Expires:0");

header(Cache-Control:must-revalidate,post-check = 0,pre-check = 0);

header(Cache-Control:private,false) ;

标题(" $ ct");

标题(''内容 - 处置:附件; filename ="''。$ filename。''" ;;'');

header(" Content-Transfer-Encoding:binary");

if ($ extlwr!=" .pdf"){

header(''Content-Length:''。$ size);

}

readfile(" $ filepath $ location");

退出;

[/ PHP]


任何想法?

再次感谢

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="zip";
$ct = "Content-type: application/octet-stream";
break;
case ($extlwr == ".mp3"):
$commonname="mp3";
$ct = "Content-type: audio/mp3";
break;
case ($extlwr == ".pdf"):
$commonname="pdf";
$ct = "Content-type: application/pdf";
break;
case ($extlwr == ".doc"):
$commonname="doc";
$ct = "Content-type: application/ms-word";
break;

}
$size = strval(filesize("$filepath$location"));

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="''.$filename.''";'');
header("Content-Transfer-Encoding: binary");
if($extlwr != ".pdf"){
header(''Content-Length: ''.$size);
}
readfile("$filepath$location");
exit;
[/PHP]

any ideas?
thanks again

推荐答案

extlwr){

case(
extlwr) {
case (


extlwr ==" .zip"):
extlwr == ".zip"):


commonname =" zip";
commonname="zip";


这篇关于下载文件的脚本一次只能下载1个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆