簡體   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