繁体   English   中英

如何在Content-Disposition标头中使用带有特殊字符的文件名?

[英]How can I use a filename with special characters in a Content-Disposition header?

我有一些php代码问题:

$link = $_GET['url'];
$name = $_GET['name'];
$str = '[wanted-web.ro]';

header("Content-Disposition: attachment; filename=$str $name");
header("Content-type: audio/mpeg;\r\n");
readfile(str_replace(' ', '_', $link));

那就是我用来保存文件的代码。 当我想将一些直接文件下载到我的计算机上时,该点在我想要的web.ro中使用时停止在点“ ”之后写入其余信息,例如:

[想要的Web

问题解决了!

非常感谢大家。 你真棒。 我结合了您的评论,结果是:

header("Content-Disposition: attachment; filename=\"[wanted-web.ro] $name.mp3\""); 

完美的工作! 非常感谢大家。 尊重!

在标题中引用文件名:

header("Content-Disposition: attachment; filename=\"$str $name\"");

http://www.ietf.org/rfc/rfc6266.txt

尝试这个:

<?php
$link = $_GET['url'];
$name = $_GET['name'];
$str = "[wanted-web.ro]";

header("Content-Disposition: attachment; filename=".$str." ".$name);
header("Content-type: audio/mpeg;\r\n");
readfile(str_replace(' ', '_', $link));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM