如果你的机器装了Word,就可以直接打开,和PHP无关

解决方案 »

  1.   

    很多邮箱都实现了这个功能,点击office文档后,直接弹出保存对话框,就算我的电脑里装了office。
      

  2.   

    $downFile = "../dirfiles/filename.doc";//可以用相对地址
    if (file_exists($downFile))
    {
    header("Content-Type: application/octet-stream");//根据下载文件类型可能有变化
    header("Content-Disposition: attachment; filename=filename.doc");//文件名可改
    header("Accept-Ranges: bytes");
    header("Accept-Length: ".filesize($downFile));
    $fh=fopen($downFile, "rb");
    echo fread($fh,filesize($downFile));
    fclose($fh);
    exit;
    }
      

  3.   

    上面的代码单独放在一个.php文件里面,里面不可以有任何的html代码,或者打印输出等。