2012-04-10 73 views
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/vzzkzp/5 readbeam

http://tinypic.com/r/2h7pbth/5 mine

回答

2

Content-Type头不匹配从readbeam之一。

application/epub zip!= application/epub+zip

+可能正在由PHP看作是一个空间,因为它似乎要通过$ _GET传递。

+0

你是绝对正确的!我现在使用'urlencode()'来解决它:) – speendo 2012-04-10 17:09:11

+0

对于未来的读者,也可以看看这个:http://stackoverflow.com/questions/15123809/force-download-only-displays-in-browser-doesnt-prompt- for-download#answer-22228190 – gibberish 2015-11-25 05:10:11

+0

@gibberish agar其他页面的部分应该在看? – 2017-11-19 22:27:51