php - 使用firefox下载时的文件名

2024-01-24

I see this http://php.net/manual/en/function.readfile.php制作下载文件的教程,但我遇到问题
这是我的例子

$file_url = "D:/my file name.doc"

header('Content-Type: text/json; charset=UTF-8;');  
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($file_url)."");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file_url));
ob_clean();
flush();
readfile($file_url);

在 ie 或 chrome 中一切都很好。但是当我使用firefox下载文件。下载的文件有my是文件名吗?如何解决这个问题谢谢


header('Content-Disposition: attachment; filename="' .basename($file_url).'"');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

php - 使用firefox下载时的文件名 的相关文章

随机推荐