Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8661403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:29:22+00:00 2026-06-12T16:29:22+00:00

<?php header(‘Content-disposition: attachment; filename=Booking.pdf’); header(‘Content-type: application/pdf’); readfile(‘http://mysite.com/Booking.pdf’); ?> why is the Booking.pdf file downloaded

  • 0
<?php
header('Content-disposition: attachment; filename=Booking.pdf');
header('Content-type: application/pdf');
readfile('http://mysite.com/Booking.pdf');
?>

why is the Booking.pdf file downloaded empty!??

mac and windows both say:
The file “Booking.pdf” could not be opened because it is empty.

checked google and stackoverflow, can’t find relative info… has anyone experienced this before?

ps: I only found this forum post:’The online issue is a bit off topic I think, but is generally due to loading the PDF to a server in the ASCII mode of FTP rather than binary. That creates a corrupt file. Be sure to turn on binary transmission‘, but this is not true in this case as i can display the same pdf file in an iframe and it is not blank/empty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:29:23+00:00Added an answer on June 12, 2026 at 4:29 pm

    You need to change

      readfile('http://mysite.com/Booking.pdf');
    

    To

      readfile(__DIR__ . '/Booking.pdf');
    

    Example

    $file = __DIR__ . '/test.pdf' ;
    header('Content-disposition: attachment; filename=Booking.pdf');
    header('Content-type: application/pdf');
    header("Content-length: ".filesize($file));
    readfile($file);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My script is the following: <?php header(Content-type:application/pdf); // It will be called downloaded.pdf header(Content-Disposition:attachment;filename='test.pdf');
Code first, then an explanation: <?php header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename=\.$_POST['filename'].\); $key = md5(rand());
this is my code to generate .doc <?php header(Content-type: application/vnd.ms-word); header(Content-Disposition: attachment; Filename=SaveAsWordDoc.doc); ?>
I have a php file like this: <?php header(Content-type: application/octet-stream); header(Content-Disposition: attachment; filename=\my-data.csv\); $data
I have this simple code in php: <?php header(Content-type: application/vnd.ms-word); header(Content-Disposition: attachment;Filename=kid_tag.doc); echo '<table
I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;
<?php header('Content-type:image/gif'); header('Content-Disposition: attachment; filename=animated.gif'); require_once('GIFEncoder.class.php'); $image = imagecreatefrompng('source01.png'); $width = 50; $height =
I have this code in PHP: header(Content-Type: application/vnd.ms-excel); header(Content-Type: application/download); header(Content-Length: .filesize($path.$filename)); header(Content-disposition: attachment;
<?php header('Content-type: application/json'); $json = file_get_contents(http://twitter.com/status/user_timeline/lindsaylohan.json?count=1); $temp = json_decode($json); $array = Array(); $array[] =
The following code does not get me the correct file: <?php header(Content-Type: application/octet-stream); readfile(http://player.vimeo.com/play_redirect?clip_id=24195442&sig=49daac0ff885745c27601a80402bba14&time=1351783454&quality=hd&codecs=H264&type=moogaloop_local&embed_location=);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.