I am having problems sending pdf files to android browser with php script. Specifically, in http://aim.shef.ac.uk/misc/a.php I have the following script:
header('Content-Type: application/pdf'); header("Content-Disposition:inline;filename=\"c.pdf\""); readfile('c.pdf');
This works as expected in various browsers on the desktop, as well as on the iPhone: the pdf file appears in the browser window, as if I looked at http://aim.shef.ac.uk/misc/c.pdf directly. However, when I try to use it on Android (2.3.3), practically nothing happens (despite the fact that there are several applications on the phone that can display pdf files). If I directly come to c.pdf, or if I change 'inline' to 'attachment', then the phone suggests saving the file, and then I can view it. This is less convenient, so I donโt want to use affection for clients who can work with inline correctly. I could just check $ _SERVER ['HTTP_USER_AGENT'] for the Android substring and install the content on it. However, this is similar to kludgy, and I do not know if this is suitable for all Android devices.
Any suggestions?
source share