Ms7 Search
Google 搜尋 翻譯
calendar
« 九月 2024 »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
近期文章
文章分類
網站連結
Syndicate

« | »

PHP utf-8 用 header 檔案下載 word error

2013-03-08 @ 23:30 in 學校網頁

以前在 big5 網頁用

header("Content-Type: application/force-download; name=\"".$file."\""); //==> 當你存檔的時候正確顯示你的檔名
header("Content-Disposition: attachment; filename=\"".$file."\""); //==> 當你存檔的時候正確顯示你的檔名
header("Content-Transfer-Encoding: binary");
readfile($df);

可以下載 word 或 pdf 的檔案

可是改成 utf-8  網頁時,下載 word 檔案就顯示無法啟動轉換程式,在網頁上找到有人說是 buffer 的問題,後來看到有人加入清 buffer 的函數,竟然就可以了,將指令修改如下

header("Content-Type: application/force-download; name=\"".$file."\""); //==> 當你存檔的時候正確顯示你的檔名
header("Content-Disposition: attachment; filename=\"".$file."\""); //==> 當你存檔的時候正確顯示你的檔名
header("Content-Transfer-Encoding: binary");
ob_clean();
flush();

readfile($df);

 

迴響

ob_clean()有用喔~很不錯的分享,解決了我的問題。

ob_clean()有用喔~很不錯的分享,解決了我的問題。

作者 網頁設計 @ 17:59, 2019-03-26

謝謝分享,有幫助到我唷

謝謝分享,有幫助到我唷

作者 felisa @ 16:23, 2019-11-06

PHP utf-8 用 header 檔案下載 word error | 豬窩

My spouse and I absolutely love your blog and find nearly
all of your post's to be what precisely I'm looking for.
Would you offer guest writers to write content available for
you? I wouldn't mind publishing a post or elaborating on many of the subjects you
write regarding here. Again, awesome web log!

作者 g those @ 15:22, 2020-06-20

PHP utf-8 用 header 檔案下載 word error | 豬窩

My brother suggested I might like this web site.

He was totally right. This post truly made my day.
You can not imagine simply how much time I had spent for this information! Thanks!

作者 g other @ 11:52, 2020-06-21

PHP utf-8 用 header 檔案下載 word error | 豬窩

I don't even understand how I stopped up right here, however
I believed this put up was good. I don't realize who
you are however certainly you are going to a well-known blogger if you are not already.
Cheers!

作者 him g @ 17:16, 2020-06-21
1 2 3 4 5 6  下一篇»
發表迴響
 authimage