2
我的電子書閱讀器(Sony PRS-T1)的內置瀏覽器不知何故不喜歡下載.epub文件。強制索尼PRS-T1瀏覽器下載.epub文件
通常它會打開.epub文件,就好像它們是文本文件一樣。
有了這個PHP下載腳本我設法迫使瀏覽器下載我的服務器我將文件存儲:現在
<?php
$path = $_GET['path'];
$mimeType = $_GET['mimeType'];
if(!file_exists($path)) {
// File doesn't exist, output error
die('file not found');
} else {
$size = filesize($path);
$file = basename($path);
// Set headers
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"$file\"");
header("Content-Type: $mimeType");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $size");
// Read the file from disk
readfile($path);
}
exit();
?>
中,PRS-T1將下載文件,但由於某種原因,我不不明白它會將文件擴展名從.epub改爲.htm - 這很奇怪。
但似乎有一種方法可以做到這一點:當我從readbeam.com下載一個.epub文件時,它就像預期的那樣工作(我在http://www.mobileread.com/forums/showthread.php?t=163466處發現了這個提示)。
這是什麼,這使得他們的配置和我的區別?
這裏是我發現使用Firebug:
http://tinypic.com/r/2h7pbth/5
你是絕對正確的!我現在使用'urlencode()'來解決它:) – speendo 2012-04-10 17:09:11
對於未來的讀者,也可以看看這個:http://stackoverflow.com/questions/15123809/force-download-only-displays-in-browser-doesnt-prompt- for-download#answer-22228190 – gibberish 2015-11-25 05:10:11
@gibberish agar其他頁面的部分應該在看? – 2017-11-19 22:27:51