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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:41:43+00:00 2026-05-22T15:41:43+00:00

Can I use the PHP code below if the PDF file is not on

  • 0

Can I use the PHP code below if the PDF file is not on my server but on a different server with a different IP? If not, what’s the best replacement?

This code fragment was taken from this PHP tutorial: http://www.devshed.com/c/a/PHP/Simple-and-Secure-PHP-Download-Script-with-Limits-Tutorial/

//Define the content type and show force download attachment dialog

header("Content-type:application/pdf");
header('Content-Disposition: attachment; filename="http://www.yourdomain.com/ebookfordownloads/ebook.pdf"');

//Stream the PDF file for downloading using PHP readfile function
//The readfile is using absolute server path
//You can determine this path by uploading a php script to the folder containing the download material.
/*
<?php
echo $_SERVER['SCRIPT_FILENAME'];
?>
*/
readfile("/your/absolute/server/path/html/ebookfordownloads/ebook.pdf");
  • 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-05-22T15:41:44+00:00Added an answer on May 22, 2026 at 3:41 pm

    Can I use the PHP code below if the PDF file is not on my server but on a different server with a different IP? If not what is the best replacement?

    Yes, that would be possible, depending on your servers settings. It will have to allow connections to other servers (allow_url_fopen should be true) to do so. Other than that, you’re golden 😉

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

Sidebar

Related Questions

In smarty templates you can use raw PHP code in a template by placing
I have been having an ongoing fight with this email setup. The code below
I have an issue with this jquery code below. Please give me advice or
(SOLVED, SEE END) I need hints on the PHP or MySQL code structure for
i have the code below <div id=topbar> <a class=nav href=# onClick=if($('#embedding').css('display') == 'none') {
Below is part of a PHP database class someone else wrote, I have removed
My goal is to be able to use $obj like this: print $obj->hello() .
I have a file that users will purchase via paypal, clickbank and paydotcom. I
Suggestions other that dumping IE6 that is... I can't control that :) Quick synopsis
Is there are way to get __callStatic, or similar, functionality in PHP 5.2? I'm

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.