Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重命名并下载mp3文件_Php_File_Rename - Fatal编程技术网

Php 重命名并下载mp3文件

Php 重命名并下载mp3文件,php,file,rename,Php,File,Rename,例如,我有一个链接: http://example.com/song.mp3 http://example.com/song.mp3 当用户下载该文件时,该文件将重命名为 artist-song.mp3 艺人-song.mp3 我使用了以下代码: <?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://example.com/song.mp3"); header('Content-Dispositio

例如,我有一个链接:

http://example.com/song.mp3 http://example.com/song.mp3 当用户下载该文件时,该文件将重命名为

artist-song.mp3 艺人-song.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))

文档中的示例正是您想要的


特别是,请参见
标题('Content-Disposition:attachment;filename='.basename($file))

位置标头使客户端浏览器从指定的URL请求文件。这将是一个全新的独立http请求,具有自己的内容类型/内容处置头


您在此处发布的内容处置标头将不被接受,因为它来自完全不同的请求。

位置标头会导致客户端浏览器从指定的URL请求文件。这将是一个全新的独立http请求,具有自己的内容类型/内容处置头


您在此处发布的内容处置标头将不受尊重,因为它来自完全不同的请求。

我正在尝试执行某些操作,但我没有重命名该文件。。也许从另一台服务器下载并重命名文件是不可能的?是的,你不能这样做。一种解决方法是使用服务器从源站下载文件,然后将其提供给浏览器。我正在尝试执行某些操作,但我没有重命名该文件。。也许从另一台服务器下载并重命名文件是不可能的?是的,你不能这样做。解决方法是使用服务器从源站下载文件,然后将其提供给浏览器。