0

Hi, i have a problem in downloading pdf files that is when i click the download button it just download a text file contains unreadable and unrecognizable words and numbers , so can any one help me to solve this problem

my code to download a pdf file is :

$DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT'];
	  
 	  $root_file = "$DOCUMENT_ROOT"."mysite2/downbooks/";
  	  
  	  $down_url = $root_file.$book_name.".pdf";

  	  header('Content-Type: application/force-download');
  	  header('Content-Type: application/octet-stream');
  	  header('Content-Type: application/download');
 	  header('Content-disposition: attachment; filename='.basename($down_url)."'");
  	  header('Content-Type: application/pdf');
          header('Content-Transfer-Encoding: binary');
  	  //header('Content-Length: ' . filesize($down_url));
  	  @readfile($down_url);
  	  exit(0);
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by sedalnas
0

I tried to this before but it doesn't work , any random thoughts may help...thanks

0
$DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT'];
	  
 	  $root_file = "$DOCUMENT_ROOT"."mysite2/downbooks/";
  	  
  	  $down_url = "$root_file.$book_name.pdf";
          header("Expires: 0");
          header("Cache-Control: must-revalidate, post-check=0, pre-check=0")
          header("Content-Description: File Transfer");    
  	  header("Content-Type: application/pdf");
 	  header("Content-disposition: attachment; filename=$book_name.pdf");
          header("Content-Transfer-Encoding: binary");
  	  header('Content-Length: ' . filesize($down_url));
  	  @readfile($down_url);
  	  exit;
0

Thanks a lot adatapost it some works fine but when i tried to open the PDF file adobe reader said that the file could be damaged or not a supported file type and the downloaded file size is not the actual size of the original file.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.