I need help regarding file download.


$id = strrchr($url,"/");
$id= substr($id,1,strlen($id));

retrieving name of the pdf from url

header('Content-disposition: attachment; filename='.$id);
header('Content-type: application/pdf');

code for downloading file

but it is not working?

So i need help from you guys.

Thanks in advance.

Recommended Answers

All 4 Replies

But it generating binary content of the file.....not working.

The Content-Type header must be sent before the Content-Disposition header.

my code

$file= $_GET;

header('Content-Description: File Transfer');
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));

even though i am getting binary content.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.