页面中,我直接放一个音频文件的链接,比如<a href="/abc.mp3"> </a>,用IE浏览器浏览的时候,点击这个链接就会直接调用播放器播放,我现在想点这个链接的时候直接弹出下载框,而不播放,请问高手该怎么实现?

解决方案 »

  1.   

    download.php?name=/abc.mp3$strFullName = $_GET['name'];
    if(file_exists($strFullName))
    {
      $filename = pathinfo($strFullName, 2);
      $nFileSize = filesize($strFullName);
      Header("Content-type: application/octet-stream");
      Header("Content-Disposition: attachment; filename=\"$filename\"");
      Header("Content-Length: $nFileSize");
      Header('Accept-Ranges: bytes');
      Header("Cache-control: private");
      Header('Pragma: private');
      Header("Expires: 0");
      echo file_get_contents($strFullName);
    }
      

  2.   

    把mp3文件放在一个特定的目录下,在apache中设定该目录的所有文件的mime类型为下载类型。