doutou19761022 2013-12-18 19:59
浏览 137

Android下载文件名与标题不对应

I am using Nexus 7 to test, any other platforms don't have same situation as far I can test on. I use handle.php to handle the download, before echo the file content, I used:

header('Content-length:' . $row['size']);
header('Content-type:' . $row['mime']);

and

header('Content-Disposition:inline; filename="' . $row["file_name"] . '"');

then I use android to download the file, the file name is however handle.pdf, if I change the last row of my code into

header('Content-Disposition:attachment; filename="' . $row["file_name"] . '"');

and interesting, the file name became what I want. Does Android fail to get file name if the Content-Disposition is inline and only accept the file name with attachment? By the way, I used the Native Chrome Browser (32.0) and in Android 4.4.2.

  • 写回答

1条回答 默认 最新

  • douao8204 2013-12-18 20:41
    关注

    Per RFC 2616, Sec 19,

    The Content-Disposition response-header field has been proposed as a means for the origin server to suggest a default filename if the user requests that the content is saved to a file. This usage is derived from the definition of Content-Disposition in RFC 1806 [35].

    Note that filename-parm is only specified for attachments, not for inline-content. While, in fact, most browsers parse the parameter and honor it, the standard doesn't call for that behavior. If you intent to deliver a file for download, you should set the content-disposition as attachment.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘