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 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line