Jump to content

Need help saving remote image


dose

Recommended Posts

So ive tried this a few times and gave up, and im attempting to do it again but running into the same problems =/

 

I wanna be able to download and save an image like this.

 

http://www.socom.com/en-us/Clan/Badge?name=the+potheads    (You will need to verify age before you can view)

 

My problem is when you goto the link it goes to another url. This is the last thing i tried, but i just get a blank image.

 

$url = "http://www.socom.com/en-us/Clan/Badge?name=the+potheads";
$ch = curl_init();
$fh = fopen("whatever.png", "wb");
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_FILE, $fh); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
$response = curl_exec($ch);
curl_close($ch);
fclose($fh);

Link to comment
https://forums.phpfreaks.com/topic/207601-need-help-saving-remote-image/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.