1.11M Members

file download problem

 
0
 

Hi

I need help regarding file download.

$url="http://".$_SERVER.$_SERVER;

$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');
readfile($id);

code for downloading file

but it is not working?

So i need help from you guys.

Thanks in advance.

 
0
 

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

 
0
 

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

 
0
 

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));
ob_clean();
flush();
readfile($file);
exit;

even though i am getting binary content.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: