2 years ago

#64401

test-img

Hamza Moghrabi

PHP download prompt does not appear when sending headers

im trying to download files (pdf or zip). im sending the correct headers

header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=$fileName.pdf");
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
print $pdf;

and i can see the headers in the browser and in headers_list().

response header

i tried multiple things but im not sure why the download never happens, and by that i mean the prompt from the broweser doesnt show (even though i can see the PDF file in the response and i can see its size 45kb sometimes).

and i can see the contents of print in the response as well.

php

download

header

0 Answers

Your Answer

Accepted video resources