PHP显示file_exists但是当调用" readFile"时,浏览器说没有收到数据或连接重置

时间:2014-04-17 18:20:44

标签: php mod-rewrite windows-server-2008

我正在尝试编写一个脚本来读取要下载的文件。这个脚本已经在我使用过的所有其他PHP服务器上运行了。但是我收到了以下错误:

(In Firefox) The connection was reset. The connection to the server was 
             reset while the page was loading.

(In Chrome) No data received. Unable to load the webpage because the 
            server sent no data

当我检查文件是否存在时,确实

//This prints "1"
echo file_exists( "my.pdf" );

但是当我尝试读出文件时,我得到了错误。

<?php
//If I remove these headers it is able to print the file data to the web page
header( "Pragma: public" );
header( "Expires: 0" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Cache-Control: private", false );
header( "Content-Type: application/pdf" );
header( "Content-Disposition: attachment; filename=\"my.pdf\";" );
header( "Content-Transfer-Encoding: binary" );
header( "Content-Length: ". filesize( "my.pdf" ) );

//If I take out this line, it works!
if ( file_exists( "my.pdf" ) ) readfile( "my.pdf" );
?> 

可能出现什么问题?

SETUP

文件大小:500K

操作系统:Windows Server 2008 R2企业版Service Pack 1

PHP: PHP版本5.4.7

模块:核心mod_win32 mpm_winnt http_core mod_so mod_access_compat mod_actions mod_alias中mod_allowmethods mod_asis mod_auth_basic mod_authn_core mod_authn_file模块mod_authz_core mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi一样mod_dav_lock的mod_dir mod_env mod_headers中mod_include负责mod_info mod_isapi mod_log_config mod_cache_disk mod_mime mod_negotiation模块的mod_proxy的mod_proxy_ajp mod_rewrite的mod_setenvif mod_ssl的mod_status的mod_php5 < / p>

upload_max_size: 2M(这比我尝试阅读的文件大)

cURL Largefile:

修改

这里是标题(打印到页面以显示其值):

Pragma: public
Expires: 0
Cache-Control: must-revalidate, post-check=0, pre-check=0
Cache-Control: private
Content-Type: application/pdf
Content-Disposition: attachment; filename="my.pdf";
Content-Transfer-Encoding: binary
Content-Length: 489936

0 个答案:

没有答案