PHP utf-8 用 header 檔案下載 word error
以前在 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()有用喔~很不錯的分享,解決了我的問題。
謝謝分享,有幫助到我唷
謝謝分享,有幫助到我唷
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!
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!
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!