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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:36:52+00:00 2026-06-05T12:36:52+00:00

I set it up so a user can download an image with the click

  • 0

I set it up so a user can download an image with the click of a button if it’s hosted on my site, but it doesn’t work for external images. Is it possible to do this with external images (using the URL) without first copying it to a folder on my servers?

This is what I use for images on my own site.

$str = $_GET['image'];
$img_name = substr(strrchr($str, '/'), 1);
$image = "../u/i/".$img_name;

if (file_exists($image)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($image));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($image));
    ob_clean();
    flush();
    readfile($image);
    exit();
}
  • 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-05T12:36:54+00:00Added an answer on June 5, 2026 at 12:36 pm

    As you can see on http://php.net/manual/en/function.readfile.php you can use external URLs.

    A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to
    specify the filename. See the Supported Protocols and Wrappers for
    links to information about what abilities the various wrappers have,
    notes on their usage, and information on any predefined variables they
    may provide.

    It’s a PHP setting: http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

    (The code doesn’t need change then.)

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

Sidebar

Related Questions

I have a credit system set up on my site where user A can
In my iphone app, the user can set whether he wants to download data
I am building a site that allows the user to download a set of
I'm developing a quick rapidshare-like site where the user can download files. First, I
My Rails application makes use of Time.zone so that each user can set their
I'm looking to implement a web based weekly planner where a user can set
I have situation where a user can manipulate a large set of data (presented
I am trying to set up a Navigation View where a user can enter
In my form I have a set of input boxes where a user can
How can I set attribute to MVC2 user control defined in single file with

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.