Search code examples
phpandroidpdfpdftkfdf

PHP force PDF download not working only for browser on Android


I use POST requests to transfer data that is needed to create the downloadable document on the fly.

When the form is submitted, the $_POST array is passed to a function that returns the path of a created FDF file.

The code:

header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="'.$file.'"');
passthru("pdftk file.pdf fill_form ".$fdf_file." output - ");
exit;

Work on all browser (Safari, Firefox, Opera, Chrome, Internet Explorer) but not in Android stock browser.

In Android browser, the download taking place but the content of the file being empty or some HTML garbage, or the browser downloading the file but ignoring my file name and trying to save the file under the name of the script that generated it.

Any help is much appreciated.

Thanks!

UPDATE!!!

the solution: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/


Solution

  • the solution:

    Android and the HTTP download file headers http://digiblog.de/2011/04/19/android-and-the-download-file-headers/