试试 application/force-download

解决方案 »

  1.   

    print_r(get_headers($url));
    看看都有什么
      

  2.   

    Array ( [0] => HTTP/1.1 200 OK [1] => Date: Fri, 17 Jan 2014 03:54:41 GMT [2] => Server: Apache/2.2.8 (Unix) PHP/5.2.14 [3] => X-Powered-By: PHP/5.2.14 [4] => Connection: close [5] => Content-Type: text/html [6] => Set-Cookie: SESSION_COOKIE=5; path=/ [7] => Cache-control: private )
      

  3.   

    头中有 Content-Type: text/html
    当然就是显示内容了去掉程序文件的 BOM 头
    注释掉 web 服务器默认的类型声明
      

  4.   

    如何注释掉web服务器的默认类型声明了?
      

  5.   


    header("Content-type: application/octet-stream");
    header("Accept-Ranges: bytes");
    header("Accept-Length:".filesize("../attachement/app_form/52d75250b03ec.doc"));
    header("Content-Disposition: attachment; filename=data.doc");
    $res=fopen("../attachement/app_form/52d75250b03ec.doc","rb");
    echo fread($res,filesize("../attachement/app_form/52d75250b03ec.doc"));
    fclose($res);
    exit();