PHP save image file [duplicate]

No need to create a GD resource, as someone else suggested.

$input="http://images.websnapr.com/?size=size&key=Y64Q44QLt12u&url=http://google.com";
$output="google.com.jpg";
file_put_contents($output, file_get_contents($input));

Note: this solution only works if you’re setup to allow fopen access to URLs. If the solution above doesn’t work, you’ll have to use cURL.

Leave a Comment