Forum Moderators: coopster
The $url parameter is the full url of the image you want to pull.
daisho.
function ShowImage ($url) {
$ch = curl_init ($url);
$img=NULL;
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec ($ch);
curl_close ($ch);
if(!$rawdata) {
SendDefaultImage();
} else {
$ct=content_type($rawdata);
if( "Content-Type: unknown"==$ct ) {
SendDefaultImage();
} else {
Header( $ct );
print $rawdata;
}
}
}
Fatal error: Call to undefined function: content_type().
i have php 4.2.3.
It doesn't have to be curl. it can be anything.
I tried to use this
$url = file_get_contents("http://www.php.net/");
$fp = fopen("php_homepage.txt", 'w');
fwrite($fp, $url);
fclose($fp);
but received error undefined file_get_contents()
can anyone help me out?
<?php$ch = curl_init ("http://static.php.net/www.php.net/images/php.gif");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec ($ch);
curl_close ($ch);
$fp = fopen("php.gif",'w');
fwrite($fp, $rawdata);
fclose($fp);
?>
function content_type (&$blob) {
if( strncmp($blob,"ÿØÿ",3) == 0 )
return "Content-Type: image/jpeg";
else if( strncmp($blob,"GIF",3) == 0 )
return "Content-Type: image/gif";
else
return "Content-Type: unknown";
}