1,105,534 Community Members

file download problem

Member Avatar
adityamadhira
Newbie Poster
23 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
pritaeas
mod_pritaeas
11,329 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 
Member Avatar
adityamadhira
Newbie Poster
23 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
edwinhermann
Junior Poster
141 posts since Sep 2009
Reputation Points: 57 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 2 [?]
 
0
 

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

Member Avatar
adityamadhira
Newbie Poster
23 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: