php实现中文文件名文件下载,php实现中文文件下载

php实现中文文件下载,试验过ie 火狐 谷歌浏览器均正常无乱码

1.[代码][PHP]代码

/*

* $filepath 文件路径

* $newfilename 下载时的命名

* download('/abc.xls','abc教学');

* 下载下来的文件将是abc教学.xls

*/

function download($filepath,$newfilename){

$id = intval($_GET['id']);

$db = model('tool');

$tool = $db->where('id='.$id)->find();

if(!$tool) $this->error('未找到您要查看的工具');

$ua = $_SERVER["HTTP_USER_AGENT"];

$pathinfo = pathinfo($filepath);

$newfilename = $newfilename.'.'.$pathinfo['extension'];

$file = fopen( $filepath ,"r");

header('Content-Type: application/octet-stream');

header("Accept-Ranges: bytes");

header("Accept-Length: ".filesize($filepath));

if (preg_match("/MSIE/", $ua)) {

header('Content-Disposition: attachment; filename="' . rawurlencode($newfilename) . '"');

} else if (preg_match("/Firefox/", $ua)) {

header('Content-Disposition: attachment; filename*="utf8\'\'' . $newfilename . '"');

} else {

header('Content-Disposition: attachment; filename="' . rawurlencode($newfilename) . '"');

}

echo fread($file, filesize($filepath));

//$db->where('id='.$id)->data($update)->update();

fclose($file);

}

序文 I. 入门指引 1. 简介 2. 简明教程 3. 安装 4. 运行时配置 II. 语言参考 5. 基本语法 6. 类型 7. 变量 8. 常量 9. 表达式 10. 运算符 11. 流程控制 12. 函数 13. 类与对象 14. 引用的解释 III. 安全 15. 安全 IV. 特点 16. 用 PHP 进行 HTTP 认证 17. Cookies 18. 文件上传处理 19. 使用远程文件 20. 连接处理 21. 数据库永久连接 22. 安全模式 23. PHP 的命令行模式 V. 函数参考 I. Apache 函数库 II. 数组函数库 III. Aspell functions [deprecated] IV. BCMath Arbitrary Precision Mathematics Functions V. Bzip2 Compression Functions VI. Calendar Functions VII. CCVS API Functions [deprecated] VIII. Windows 的 COM 支持函数库 IX. 类/对象函数库 X. ClibPDF Functions XI. Crack Functions XII. CURL, Client URL Library Functions XIII. Cybercash Payment Functions XIV. Cyrus IMAP administration Functions XV. Character Type Functions XVI. Database (dbm-style) Abstraction Layer Functions XVII. 时间日期函数库 XVIII. dBase Functions XIX. DBM Functions [deprecated] XX. dbx Functions XXI. DB++ Functions XXII. Direct IO Functions XXIII. 目录函数库 XXIV. DOM XML Functions XXV. .NET Functions XXVI. Error Handling and Logging Functions XXVII. File Alteration Monitor Functions XXVIII. FrontBase Functions XXIX. filePro Functions XXX. 文件系统函数库 XXXI. Forms Data Format Functions XXXII. FriBiDi Functions XXXIII. FTP 函数库 XXXIV. Function Handling Functions XXXV. Gettext XXXVI. GMP Functions XXXVII. HTTP 相关函数库 XXXVIII. Hyperwave Functions XXXIX. Hyperwave API Functions XL. iconv Functions XLI. 图像函数库 XLII. IMAP, POP3 and NNTP Functions XLIII. Informix Functions XLIV. InterBase Functions XLV. Ingres II Functions XLVI. IRC Gateway Functions XLVII. PHP / Java Integration XLVIII. LDAP Functions XLIX. LZF Functions L. Mail Functions LI. mailparse Functions LII. 数学函数库 LIII. Multi-Byte String Functions LIV. MCAL Functions LV. Mcrypt Encryption Functions LVI. MCVE Payment Functions LVII. Mhash Functions LVIII. Mimetype Functions LIX. Microsoft SQL Server Functions LX. Ming functions for Flash LXI. Miscellaneous Functions LXII. mnoGoSearch Functions LXIII. mSQL Functions LXIV. MySQL 函数库 LXV. Improved MySQL Extension LXVI. Mohawk Software Session Handler Functions LXVII. muscat Functions LXVIII. Network Functions LXIX. Ncurses Terminal Screen Control Functions LXX. Lotus Notes Functions LXXI. NSAPI-specific Functions LXXII. Unified ODBC Functions LXXIII. Object Aggregation/Composition Functions LXXIV. Oracle 8 函数库 LXXV. OpenSSL Functions LXXVI. Oracle 函数库 LXXVII. Ovrimos SQL Functions LXXVIII. 输出控制函数 LXXIX. Object property and method call overloading LXXX. PDF functions LXXXI. Verisign Payflow Pro Functions LXXXII. PHP Options&Information LXXXIII. POSIX Functions LXXXIV. PostgreSQL 数据库函数库 LXXXV. Process Control Functions LXXXVI. Program Execution Functions LXXXVII. Printer Functions LXXXVIII. Pspell Functions LXXXIX. GNU Readline XC. GNU Recode Functions XCI. 正则表达式函数库(Perl 兼容) XCII. qtdom Functions XCIII. 正则表达式函数库(POSIX 扩展) XCIV. Semaphore, Shared Memory and IPC Functions XCV. SESAM Database Functions XCVI. Session Handling Functions XCVII. Shared Memory Functions XCVIII. SimpleXML functions XCIX. SOAP Functions C. SQLite CI. Shockwave Flash Functions CII. SNMP 函数库 CIII. Socket Functions CIV. Standard PHP Library (SPL) Functions CV. Stream Functions CVI. 字符串处理函数库 CVII. Sybase Functions CVIII. TCP Wrappers Functions CIX. Tidy Functions CX. Tokenizer Functions CXI. URL 函数库 CXII. 变量函数库 CXIII. vpopmail Functions CXIV. W32api 函数库 CXV. WDDX Functions CXVI. XML 语法解析函数库 CXVII. XML-RPC 函数库 CXVIII. xdiff Functions CXIX. XSLT Functions CXX. YAZ Functions CXXI. YP/NIS Functions CXXII. Zip File Functions (Read Only Access) CXXIII. Zlib Compression Functions VI. Zend API 24. Overview 25. Extension Possibilities 26. Source Layout 27. PHP's Automatic Build System 28. Creating Extensions 29. Using Extensions 30. Troubleshooting 31. Source Discussion 32. Accepting Arguments 33. Creating Variables 34. Duplicating Variable Contents: The Copy Constructor 35. Returning Values 36. Printing Information 37. Startup and Shutdown Functions 38. Calling User Functions 39. Initialization File Support 40. Where to Go from Here 41. Reference: Some Configuration Macros 42. API Macros VII. PHP API: 扩展开发接口 43. Streams API for PHP Extension Authors VIII. FAQ: 常见问题 44. 一般信息 45. 邮件列表 46. 获取 PHP 47. 数据库问题 48. 安装 49. 编译问题 50. 使用 PHP 51. PHP 和 HTML 52. PHP 和 COM 53. PHP 和其它语言 54. 从 PHP/FI 2 移植到 PHP 3 55. 从 PHP 3 移植到 PHP 4 56. 杂类问题 IX. 附录 A. PHP 及其相关工程的历史 B. Migrating from PHP 4 to PHP 5 C. 从 PHP 3 移植到 PHP 4 D. 从 PHP/FI 2 移植到 PHP 3 E. PHP 的调试 F. 扩展 PHP 3 G. 函数别名列表 H. 保留字列表 I. 资源类型列表 J. 支持的协议/封装协议列表 K. 所支持的套接字传输器(Socket Transports)列表 L. PHP 类型及比较符表 M. 解析器代号列表 N. 关于本手册 O. Open Publication License P. 函数索引 Q. 补充说明 X. 微软 HTML 帮助版本 57. 关于此版本 58. Using PHP Manual CHM Edition 59. The Full Text Search 60. Specialities of this Edition 61. Integrating the PHP Manual 62. Skin development 63. CHM Edition Credits
php开发人员的文档,并且是中文的。 PHP 手册 Mehdi Achour Friedhelm Betz Antony Dovgal Nuno Lopes Philip Olson Georg Richter Damien Seguy Jakub Vrana 其他贡献者 编辑 Gabor Hojtsy 王远之 肖理达 肖盛文 黄啸宇 宋琪 陈伯乐 刘铭 崔岩 2005-11-18 版权 © 1997-2005 PHP 文档组 -------------------------------------------------------------------------------- 前言 作者和贡献者 I. 入门指引 1. 简介 2. 简明教程 II. 安装与配置 3. 安装前需要考虑的事项 4. Unix 系统下的安装 5. Mac OS X 系统下的安装 6. Windows 系统下的安装 7. PECL 扩展库安装 8. 还有问题? 9. 运行时配置 III. 语言参考 10. 基本语法 11. 类型 12. 变量 13. 常量 14. 表达式 15. 运算符 16. 流程控制 17. 函数 18. 类与对象(PHP 4) 19. 类与对象(PHP 5) 20. 异常处理 21. 引用的解释 IV. 安全 22. 简介 23. 总则 24. 以 CGI 模式安装时 25. 以 Apache 模块安装时 26. 文件系统安全 27. 数据库安全 28. 错误报告 29. 使用 Register Globals 30. 用户提交的数据 31. 魔术引号 32. 隐藏 PHP 33. 保持更新 V. 特点 34. 用 PHP 进行 HTTP 认证 35. Cookie 36. 会话 37. 处理 XForms 38. 文件上传处理 39. 使用远程文件 40. 连接处理 41. 数据库永久连接 42. 安全模式 43. PHP 的命令行模式 VI. 函数参考 I. .NET 函数 II. Apache 特有函数 III. Alternative PHP Cache IV. Advanced PHP debugger V. Array 数组函数 VI. Aspell 函数(已废弃) VII. BC math 高精度数学函数 VIII. PHP bytecode Compiler IX. Bzip2 压缩函数 X. Calendar 日历函数 XI. CCVS API Functions [deprecated] XII. Classes/Objects 类/对象函数 XIII. Classkit Functions XIV. ClibPDF Functions XV. COM 和 .Net(Windows)函数 XVI. Crack Functions XVII. Character Type Functions XVIII. CURL, Client URL Library Functions XIX. Cybercash Payment Functions XX. Credit Mutuel CyberMUT functions XXI. Cyrus IMAP administration Functions XXII. Date/Time 日期/时间函数 XXIII. DB++ Functions XXIV. Database (dbm-style) Abstraction Layer Functions XXV. dBase Functions XXVI. DBM Functions [deprecated] XXVII. dbx Functions XXVIII. Direct IO Functions XXIX. Directory 目录函数 XXX. DOM Functions XXXI. DOM XML Functions XXXII. Error Handling and Logging Functions XXXIII. Exif Functions XXXIV. Expect Functions XXXV. File Alteration Monitor Functions XXXVI. Forms Data Format Functions XXXVII. filePro Functions XXXVIII. Filesystem 文件系统函数 XXXIX. Firebird/InterBase Functions XL. Firebird/Interbase Functions (PDO_FIREBIRD) XLI. FriBiDi Functions
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值