php - 使用firefox下载文件的文件名 [英] php - Filename of file when using firefox to download

查看:166
本文介绍了php - 使用firefox下载文件的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这个教程来下载文件,但是我有一个问题

这是我的例子

I see this tutorial to make download file but I have a problem
Here is my example

$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 下载文件。文件下载有我的是文件名吗?如何解决这个谢谢

Everything's well in ie or chrome. But when I using firefox to download file. The file download has my is the file name? How to fix that thanks

推荐答案

header('Content-Disposition: attachment; filename="' .basename($file_url).'"');

这篇关于php - 使用firefox下载文件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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