$mime_type="application/octetstream";
header('Content-Type: ' . $mime_type);
header('Content-Disposition: inline; filename="' . $fname.".".$ftype . '"');
@readfile($downfile);为何这样无法实现下载而是打开一个临时文件提示找不到内容?难道需要加上那些其他的?

解决方案 »

  1.   

    "' . $fname.".".$ftype . '"'
    路径有没有错误啊出去验证下
      

  2.   

    路径没有错误。我加了header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    以后就可以找到位置了。
    但是点击txt文件的,还是直接打开,如果我不是另存为的话,不会弹出下载窗口,而是直接下载到临时文件夹并打开。怎么让它点击即下载?另外,header("Content-Length: ".$fcon[fsize]);及header('Pragma: public');这两行是否需要加上?有没有必要?