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 8254083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:05:10+00:00 2026-06-08T01:05:10+00:00

My script is the following: <?php header(Content-type:application/pdf); // It will be called downloaded.pdf header(Content-Disposition:attachment;filename=’test.pdf’);

  • 0

My script is the following:

<?php
header("Content-type:application/pdf");

// It will be called downloaded.pdf
header("Content-Disposition:attachment;filename='test.pdf'");

// The PDF source is in original.pdf
readfile("www.example.com/test.pdf");
?>

Now if I change readfile to say:

// The PDF source is in original.pdf
readfile("test.pdf");

It works fine, if however I specify and absolute URL, readfile("www.example.com/test.pdf");

the PDF does not open up. The above only seems to work locally.

Does anybody know why absolute url’s are not working? Cheers

Solution:

// The PDF source is in original.pdf 

readfile($_SERVER['DOCUMENT_ROOT']."/test.pdf"); 

This function only works with absolute paths, not urls.

  • 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-08T01:05:11+00:00Added an answer on June 8, 2026 at 1:05 am
    • You are missing the protocol: http://
    • And check your allow_url_fopen settings!
    • Turn on error reporting

    .

    ini_set('display_errors', true);
    error_reporting(E_ALL);
    

    A smarter approach would be to store/cache the remote file localy, so you don’t have to download it every time. And it would take the load off the target site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following PHP code $filename = 'a56.flv'; $file = C:/xampp/htdocs/site/flv/a56.flv; header(Content-Type: application/force-download); header('Content-Type:
I'm currently using the following script-- <?php // Set the content-type header('Content-type: image/png'); //
I have the following PHP script : <?php header('Content-type: text/xml'); mysql_connect('localhost', 'root', 'root'); mysql_select_db('sportApp');
I have a script that generates a csv file using the following code: header('Content-type:
I have the following script to let a visitor download a file: header( 'Content-Type:
Imagine the following: <img src=/image.php?image=5.jpg /> Now, in image.php : header('content-type: image/jpeg'); $image =
I have the following script validation.php <?php if(!isset($_SESSION['userId'])){ session_destroy(); header('Location: home.php'); exit; } ?>
I have the following PHP script: <?php $vote_type = $_GET['type']; $book = $_GET['book']; $id
I'm using the following script to initiate file downloads: if (file_exists($newfilename)) { header('Content-Description: File
I am using the following php script to show a random image on my

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.