Php 带zend的资产抓取器,大文件下载量仅为229或228字节

Php 带zend的资产抓取器,大文件下载量仅为229或228字节,php,windows,apache,zend-framework,Php,Windows,Apache,Zend Framework,我的服务器有以下问题,有很多变量在起作用。事情就是这样。当我在fedora上开发了一个桌面上有zend的小Web应用程序时,一切都很完美。然后我将应用程序传输到dreamhost上的服务器上,一切正常。 因此,中国需要一台服务器的客户机出现了问题,因为他们位于长城防火墙之后,他们希望更快地传输文件。他们有巨大的文件,大约3.4GB。所以他们给了我Windows2003虚拟机,他们不能把它改成linux,那时候一切都在下降 基本上,我的应用程序在documentroot之外有一个文件夹,所有文件都

我的服务器有以下问题,有很多变量在起作用。事情就是这样。当我在fedora上开发了一个桌面上有zend的小Web应用程序时,一切都很完美。然后我将应用程序传输到dreamhost上的服务器上,一切正常。
因此,中国需要一台服务器的客户机出现了问题,因为他们位于长城防火墙之后,他们希望更快地传输文件。他们有巨大的文件,大约3.4GB。所以他们给了我Windows2003虚拟机,他们不能把它改成linux,那时候一切都在下降

基本上,我的应用程序在documentroot之外有一个文件夹,所有文件都将通过ftp上传。我的应用程序读取文件,只允许登录用户下载文件

这是我的插件控制器

<?php

class Mapache_Controller_Plugin_AssetGrabber
 extends Zend_Controller_Plugin_Abstract
{

    public function dispatchLoopStartup (Zend_Controller_Request_Abstract $request)
    {
        if ($request->getControllerName() != 'assets')
            return;

        $auth = Zend_Auth::getInstance();
        if (!$auth->hasIdentity()) 
            throw new Exception('Not authenticated!');

        //$file = APPLICATION_PATH . '/../assets/' . $request->getActionName();
        $file = APPLICATION_PATH . '/..' . $_SERVER['REQUEST_URI'];

        $file = str_replace("_", " ", $file);
//      echo $file;
        if (file_exists($file)) {
            header("Content-type: ".$this->new_mime_content_type($file));
            header('Content-disposition: attachment;');
            //header('Content-type: '.$this->new_mime_content_type($file));
            //readfile('$file');
            echo file_get_contents($file);
        }
    }

    function new_mime_content_type($filename){
        $result = new finfo();

        if (is_resource($result) === true){
            return $result->file($filename, FILEINFO_MIME_TYPE);
        }

        return false;
    }

}

我找到了答案,我需要正确下载文件

header('Content-Disposition: attachment;filename="'.basename($file).'"');
                        header('Content-Description: File Transfer');
                        //header('Content-Type: application/octet-stream');
                        header('Content-type: '.$this->new_mime_content_type($file));
                        header('Content-Disposition: attachment; filename='.basename($file));
                        header('Content-Transfer-Encoding: binary');
                        header('Expires: 0');
                        header('Cache-Control: must-revalidate');
                        header('Pragma: public');
                        header('Content-Length: ' . filesize($file));
                        set_time_limit(0);
                        $filex = @fopen($file,"rb");
                        while(!feof($filex))
                        {
                                print(@fread($filex, 1024*8));
                                ob_flush();
                                flush();
                        }

                        //ob_clean();
                        //flush();
                        //readfile($file);

确定“文件存在”返回的是真的吗?是的,但我已经修复了它,我在下面发布了答案