PHP Grab Remote Image 2
$30-100 USD
Paid on delivery
I'm trying to grab an image from a yahoo site. I dont know the image type.
I can get the header type and then pass this content type to the fopen function it wont work. If I hard code the content type I can see the image.
Since I dont know the image type I need to grab it first then pass it to.
Once I get this going I need to save the image.
Heres my code
// open the file in a binary mode
$name= '[url removed, login to view]';
$headers = get_headers($name);
$image_type = '"Content-Type: image/'.substr($headers[7], 20, 4).'"';
$image_type2 = 'Content-Type: image/'.substr($headers[7], 20, 4) ;
//echo $image_type2 ;
// open the file in a binary mode
$fp = fopen($name, 'rb');
// send the right headers
header("Content-Type: image/gif");
//header(".$image_type2.");
header("Content-Length: " . filesize($name));
// dump the picture and stop the script
fpassthru($fp);
exit;
Project ID: #3466602