作者TaiKeDa (科科)
看板PHP
标题Re: [请益] 下载时改变档名
时间Thu Aug 12 22:43:57 2010
<?php
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'
.mb_convert_encoding($fname,'big5','UTF-8').'"');
header('Content-Transfer-Encoding: binary');
readfile($fpath);
exit;
//$fname 为 希望的档案名称
//mb_convert_encoding 将其从 big5 转为 utf8
//$fpath 为 档案路径
?>
※ 引述《newyellow (newyellow)》之铭言:
: 请问要怎麽样让 下载档案时
: 档案的名称可以即时改变?
: 例如说
: 有一个档案 phpDocument.doc
: 然後可以让使用者下载 phpDocument.doc 时
: 载下来的档名是其他的名称 比如说 php文件.doc
: 因为在做後台时
: 让使用者上传档案 用英文存档比较不会有问题
: 再加上为了避免使用者上传同档名档案会盖掉
: 通常上传时都会让档名加上一些有的没有
: 但我想要让使用者在下载的时候可以更直觉
: 所以想要这样子做
: 请问这样子要怎麽做呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 120.101.9.24
1F:推 newyellow:非常谢谢您 !!! :) 08/12 23:59
2F:→ TaiKeDa:别客气 :) 08/13 00:30