[英]How can I use a filename with special characters in a Content-Disposition header?
I have a problem with some php code: 我有一些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));
That is the code I use to save files. 那就是我用来保存文件的代码。 When I want to download some direct files to my computer, that dot what I use in
wanted-web.ro stop writing the rest of information after dot "
. ", such like this:
当我想将一些直接文件下载到我的计算机上时,该点在我想要的web.ro中使用时
将停止在点“
。 ”之后写入其余信息,例如:
[wanted-web
[想要的Web
Problem SOLVED! 问题解决了!
Thank you verry much to all. 非常感谢大家。 You are awesome.
你真棒。 I combined your comments, and the result is:
我结合了您的评论,结果是:
header("Content-Disposition: attachment; filename=\"[wanted-web.ro] $name.mp3\"");
That work perfect! 完美的工作! Thanks very much to all.
非常感谢大家。 Respect!
尊重!
Quote the filename in the header: 在标题中引用文件名:
header("Content-Disposition: attachment; filename=\"$str $name\"");
http://www.ietf.org/rfc/rfc6266.txt http://www.ietf.org/rfc/rfc6266.txt
Try this: 尝试这个:
<?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.