I am having a problem with setting up PDF download in Mozilla or Internet Explorer, as you probably got from the title. If I attempt to download something.pdf for whatever reason it becomes 'something.pdf' with the single quotes on the outside, and this of course makes it impossible to read because it is not a valid file extension. I have been looking for people experiencing the same problem, and came across very few instances, none of which had solutions that worked for me. I am pretty lost and have been trying to figure this one out for a while, and so here I am. Following is the part of the code where the download occurs. The PHP variable $OrderNumber is simply a five digit number, and $FileNameToDownload is an entire directory pointing to the location of the PDF (which I have checked to verify that is does not have single quotes).
header('Content-Description: File Transfer');
header('Content-Type: application/zip');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename='$OrderNumber'");
header("Content-Transfer-Encoding: binary ");
header('Content-Length: ' . filesize($FileNameToDownload));
while(ob_get_level()) ob_end_clean();
flush();
readfile($FileNameToDownload);
The only browsers that there is an issue in is Mozilla and IE. In Chrome and Opera it seems to work perfectly fine. Any help at all would be appreciated, as I've been stuck for a while without moving forward. If there is an alternate way of downloading PDFs I am very open to it, but all methods I found and tried besides this one gave me security errors in the console because of where it was trying to pull the PDF from. Thank you very much, and if any more detail is needed I would be happy to provide it, but I tried to be as thorough as I could.