duanrong5167 2013-04-14 12:55
浏览 44
已采纳

从标题下载时缺少文件扩展名

i'm using the below code to download a file, which work's well but the problem is that the file extension is missing, even after stressful download . i have tried changing it to other MIME types, what could be the problem and how do i solve it ?

header('Content-Type: audio/mp3');
header("Content-Disposition: attachment; filename=$row[3]");
header("Content-Length: ".filesize("$row[1]$row[2]"));
$fp = fopen("$row[1]$row[2]", "r");
fpassthru($fp);
fclose($fp);

NOTE: the values in the $row array are fine.

  • 写回答

3条回答 默认 最新

  • dongluoheng3324 2013-04-14 13:01
    关注

    Just a shot in the dark here, could it be that the filename has a space in it? In that case you can try to add double quotes around the filename, there are reports about parts after a space being omitted (e.g. here: http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download)

    Edit: As discussed in the comments, the headers did not return the extension, so adding the .mp3 extension manually in the back-end solves this problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部