使用文件流下载。
注意设置:ContentType = "application/octet-stream"

解决方案 »

  1.   

    不对吧,人家要下载的是个txt文件,怎么在txt文件里加http头啊楼主的问题我也遇到过,一般ie就可以正常下载,firfox就直接读取文件内容了一下,等高人指点
      

  2.   

    1.用php文件来间接下载txt
    2.改apache里关于txt的文件头
      

  3.   

    <?php
    header("Content-type: application/octet-stream");
    header("Content-disposition: attachment; filename=\"test.txt\"");
    ?>
      

  4.   

    header("content-type:   application/file"); 
    header("content-disposition:   attachment;   filename=\"test.txt\"");这个应该可以,我以前用过
      

  5.   

    问题已解决
    $file_name = basename($file);
    $handle = fopen($file,"r");
    header("Content-Type: application/force-download");          //强制下载
    header("Content-Disposition: attachment; filename=".basename($file_name)); //下载保存的文件名
    echo fread($handle,filesize($file));
    fclose($handle);