我正在将文件名传递给下载页面。
即 somefile.xls
下载页面将完整目录路径添加回文件名。
即 c:\temp\somefile.xls
问题是现在设置标题的“Content-Disposition”不起作用。它要下载的文件名是完整的目录文件名路径。 即 c_temp_somefile
Content-Disposition 可以处理完整路径吗?
如果可以,我如何让我的脚本正确下载文件?
代码是:
$myad = $_GET['myad'];
$glob_string = realpath('/foldera/folderb/folderc'). DIRECTORY_SEPARATOR .$myad;
header('Content-Type: application/excel');
$headerstring = 'Content-Disposition: attachment; filename='.$glob_string;
header($headerstring);
readfile($myad);
更新代码(来自答案):
$myad = $_GET['myad'];
$glob_string = realpath('/mit/mit_tm/mrl_bol'). DIRECTORY_SEPARATOR .$myad;
header('Content-Type: application/excel');
$headerstring = 'Content-Disposition: attachment; filename='.$myad;
header($headerstring);
readfile($glob_string);