cURL / Mailing Lists / curl-library / Single Mail


Re: PNG Image resolution

From: Dan Fandrich <>
Date: Thu, 29 Dec 2011 23:55:14 -0800

On Thu, Dec 29, 2011 at 10:29:44PM -0500, Robert Ingoglia wrote:
> I am very new to all of this, but if you fine folks would tolerate a ‚
> newbie,‚ I would be most appreciative.


> To be very brief, I wrote my very first cURL script within a php file and
> uploaded it to my website:

You should note that this mailing list is for users of the C libcurl
binding, not PHP. Try the curl-and-php list in the future.

> However, when I modify the name of the url (so that a grapic file with a png
> extension is ‚ pointed to‚ ):
> <?php
> $curl = curl_init();
> curl_setopt ($curl, CURLOPT_URL, "
> hydrographs/lodn4_hg.png");
> curl_exec ($curl);
> curl_close ($curl);
> ?>
> ‚ ¶The picture does not show up (as a picture) but as gibberish:

That's because a PNG image contains binary data, not text, and depending
on the web server configuration, it will probably send a text/html
Content-Type for the page unless specified otherwise. Try adding the line:

header ("Content-Type: image/png");

somewhere before the curl_exec call and it should solve the problem.

>>> Dan
List admin:
Received on 2011-12-30