重命名并下载mp3文件 [英] Rename and download mp3 file
本文介绍了重命名并下载mp3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如我有链接:
http://example.com/song.mp3
当用户下载文件时,文件将被重命名为
$ b艺术家歌曲.mp3
我使用这段代码:
<?php
header(HTTP / 1.1 301 Moved Permanently);
header(Location:http://example.com/song.mp3);
header('Content-Disposition:attachment; filename =a-s.mp3');
exit();
?>
但是不行。我需要做什么?
解决方案
文档中的示例非常符合您的需求。
尤其请参阅头文件('Content-Disposition:attachment; filename ='。basename($ file));
位
for example i have link :
http://example.com/song.mp3
and when user download it, file will be renamed to
artist-song.mp3
I used this code :
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://example.com/song.mp3");
header('Content-Disposition: attachment; filename="a-s.mp3"');
exit();
?>
But it doesn't work. What do I need to do?
解决方案
the example in the docs is pretty much what you want.
in particular, see the header('Content-Disposition: attachment; filename='.basename($file));
bit
这篇关于重命名并下载mp3文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文