Php下载文件以从不同的文件夹中读取

时间:2013-11-17 10:45:14

标签: php

我正在使用Zubarg智能文件下载,强制我的用户使用以下方式下载音频文件:

download.php?f=FileName

我希望这个download.php能够读取来自不同文件夹的mp3文件:

define('BASE_DIR','downloads/');

如何在上面添加多个目录来读取?

由于

1 个答案:

答案 0 :(得分:0)

这是您需要的代码。

    header("Content-Description: File Transfer;");
       header('Content-Type: audio/mpeg');
header('Content-Disposition: attachment, filename="' . $temp['file'] . $temp['fileext'].'";');  

header("Content-Length: ".filesize(BASE_DIR.$temp['file']));
readfile(BASE_DIR.$temp['file']);
相关问题