![]() If you want to serve files other than PDF, remove or edit line 5.Īdd the following link to your HTML file. Save this little snippet as a PHP file somewhere on your server and you can use it to make a file download in the browser, rather than display directly. But currently I'm not working on that platform. Generally it happens, because some browsers settings or plug-ins directly open PDF in the same window like a simple web page. Note that this is just an extension to the HTTP protocol some browsers might ignore it anyway. Readfile($path) // This is necessary in order to get it to actually download the file, otherwise it will be 0Kb $filename) // Make the browser display the Save As dialog Header('Content-Disposition: attachment filename='. Header('Content-Type: application/pdf') // Change the mime type if the file is not PDF Header('Accept-Ranges: bytes') // Allow support for download resume gmdate('D, d M Y H:i:s', filemtime($path)). Header('Content-Transfer-Encoding: binary') // For Gecko browsers mainly Here's a PHP code example: $path = "path/to/file.pdf" If you still want to force the browser to download the file, modify the HTTP headers directly. The user can always force their browser to download the file if they wish to. Generally you shouldn't even do this - it should be left up to the user/user agent to decide what do to with the content you provide. Meta tags are not a reliable way to achieve this result.
0 Comments
Leave a Reply. |