代码之家  ›  专栏  ›  技术社区  ›  Ben

MP3下载不工作

  •  0
  • Ben  · 技术社区  · 15 年前

    我提供了一个讲道下载网站,有一个用户在下载时遇到问题。任何人都对我如何改进这段代码有任何想法,或者发送更好的消息头…

    $path = "http://www.domain.com/sermon_files/".date("Y", $array["preached"])."/".$array["filename"];
    $corePath = "/home/user/public_html/sermon_files/".date("Y", $array["preached"])."/".$array["filename"];
    if (!file_exists($corePath)) {
        echo "An error has occured with this download.";    
    } else {
        header("Pragma: public"); // required
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false); 
        header("Content-Type: audio/mp3");
        header("Content-Disposition: attachment; filename=\"".$array["title"]."\";" );
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: ".filesize($corePath));
        readfile($path);
        exit();
    }
    
    3 回复  |  直到 15 年前
        1
  •  0
  •   Community CDub    8 年前

    看看这条线,我也遇到了类似的问题: PHP: Force file download and IE, yet again . 还可以考虑使用fiddler捕获发送到客户机的确切HTTP头。

        2
  •  0
  •   empc    15 年前

    结合你的php(?)使用具有x-send可用的服务器编码, lighttpd 确实如此吗 apache

        3
  •  0
  •   SpliFF    15 年前

    下载时注意过期:0。这干扰了IE6的小大脑,使它认为没有数据可以保存/打开。尝试在访问后的一分钟内到期,看看是否解决了问题。否则,告诉我们问题到底是什么。