【发布时间】:2015-05-05 00:47:17
【问题描述】:
我有一组指向 mp3 文件的链接。我需要从服务器下载所有 mp3,然后压缩。
下面的代码不起作用:
有什么建议吗?
$audio_flies = array('http://example.com/1.mp3','http://example.com/2.mp3');
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($audio_files as $file) {
echo "$file";
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
存档格式未知或已损坏
【问题讨论】:
-
你在这段代码的哪里下载文件?!你确定
addFile()封装了下载过程吗? (我非常怀疑) -
到目前为止我还没有下载它们。这是我需要帮助的一种。抱歉,我的问题不太清楚。