I pass the address of the php file that contains the following code as a parameter to the file viewer.htmland it displays correctly, but when I click the download button in the PDF viewer, the document name is always document.pdf. This creates a problem due to how many mobile users will download files only to detect that all their files have a name document.pdfand that (for most mobile browsers) they cannot change the file name before downloading.
Should I pass any arbitrary parameter to the file or redirect to itself with the attached file name?
<?php
$content = "a binary representation of my pdf";
header("Content-type: application/pdf");
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="someFile.pdf"');
echo $content;
?>
source
share