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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:45:59+00:00 2026-05-25T14:45:59+00:00

I am attempting to use cURL to download an image from an external server.

  • 0

I am attempting to use cURL to download an image from an external server. This code works on my local Windows XAMPP installation:

$ch = curl_init("http://some.server.com/some-image.jpg");
$fp = fopen("testimage.jpg", 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);

However, when I take that exact same code and run it on my production server, the image does not get successfully downloaded. testimage.jpg gets created, but with a 0 file size. A call to curl_errno returns 0. Are there any system settings that affect how cURL operates?

For the record, the url I am using does cause a redirect to occur. When I enter the url into a browser, a different url ends up in the address bar when the image is displayed. However, I was under the impression that CURLOPT_FOLLOWLOCATION was all that was needed to follow redirects, particularly because this is all that I need to make this work locally. Am I missing something?

  • 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-25T14:46:00+00:00Added an answer on May 25, 2026 at 2:46 pm

    Firstly make sure you explicitly envoke display errors and error_reporting by adding the following:

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

    Also check your firewall settings to ensure that the request can successfully be sent through.

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

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
When attempting to use HttpWebRequest to retrieve a page from my dev server, I
I'm attempting to use the code from http://www.codeproject.com/Articles/20165/CheckBox-Header-Column-For-DataGridView in order to add a CheckBox
In attempting to use std::select1st from <functional> in a VS2008 project I found that
I am attempting to use the following code to search a database using words
I'm attempting to pass a key via the $_SERVER['HTTP_REFERER'] (set via cURL) from one
I am attempting to use PHP and cURL to: Access a web-form & maintain
I am attempting to use the MediaStore.ACTION_VIDEO_CAPTURE in my app, see code below. However,
I am attempting to use background-image:url('path/to/image.png'); to place a background image in a div
I'm attempting to use jsoup to sanitize the the html posted from a wysiwyg

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.