0
我有一個網站,MP3的下載完成後,當我下載它通過PHP(捲曲)這首歌被下載,但就像專輯封面歌曲的元數據,藝術家姓名等是丟失。PHP曲mp3下載正在重置元數據
在服務器上文件有所有的數據,但下載時一切都丟失了。 繼承人我的代碼:
if (!empty($path) && $path != null)
{
$ch = curl_init($path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false)
{
echo 'CURL Failed';
exit;
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches))
{
$contentLength = (int) $matches[1];
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false); // required for certain browsers
header('Content-Type: audio/mpeg');
header("Content-Disposition: attachment; filename=\"" . urlencode($song->title) . ".mp3\";");
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $contentLength);
ob_clean();
flush();
echo $data;
exit;
}
是否有可能也重命名文件? –
很酷,它的工作,我剛剛添加了'header(「Content-Disposition:attachment; filename = \」「。urlencode($ song-> title)。」.mp3 \「;」);'它工作,非常感謝伴侶 –