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.
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
.