php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53576 Problem in download pdf files
Submitted: 2010-12-19 21:39 UTC Modified: 2010-12-20 00:46 UTC
From: husseinwajeeh at gmail dot com Assigned:
Status: Not a bug Package: PDF related
PHP Version: 5.2.16 OS: Windows 7
Private report: No CVE-ID: None
 [2010-12-19 21:39 UTC] husseinwajeeh at gmail dot com
Description:
------------
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 :

Test script:
---------------
    $DOCUMENT_ROOT=$_SERVER['DOCUMENT_ROOT'];
	  
    $root_file = "$DOCUMENT_ROOT"."mysite2/downbooks/";
    $book_name = str_replace(" ","",$book_name);
    $down_url = $root_file.$book_name;
    
    header('Prgrama: public');
    header('Content-Type: application/pdf');
    header('Content-Type: application/force-download');
    header('Content-Type: application/octet-stream');
    header('Content-Type: application/download');
    header('Content-disposition: attachment; filename='.$book_name.";");	  
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($down_url));
    @readfile($book_name.".pdf");
    exit;

Expected result:
----------------
download a pdf file

Actual result:
--------------
i just get a plain text file contains unreadable and unrecognizable words and numbers.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-20 00:46 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-12-20 00:46 UTC] johannes@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat May 25 21:01:27 2019 UTC