【发布时间】:2012-04-11 20:35:11
【问题描述】:
浏览到以下地址后,我想显示一个 PDF 文件:
http://www.mydomain.com/myfile
为此,我在.htaccess 上使用301 重定向,它将myfile 重定向到myfile.php。该文件然后包含
<?php
$filename = 'files/somefile.pdf';
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="somefile.pdf"');
header('Content-Length: ' . filesize($filename));
@readfile($filename);
?>
主要思想是PDF显示在浏览器中而不提示用户下载,但是当强制下载时输出文件名变为somefile.pdf。一切在 IE、Firefox、Chrome、Safari 和 Opera 中运行顺利。但是,在 Android 中没有任何反应。 PDF 不显示,也不提示下载。我怎样才能让它与Android一起工作?我需要在脚本中更改什么吗?
【问题讨论】: