Jump to content

[SOLVED] Get Image from URL


gingle

Recommended Posts

Hi, I'm trying to download an image from a safe url. Im using a

service caller snapcasa which creates thumbnails from an url. I'd like

to download this image but as you can see on this url, there isnt a

jpeg extenson.

 

How can I do it with php

 

example: http://snapcasa.com/get.aspx?code=4824&size=l&url=www.google.ca

Link to comment
https://forums.phpfreaks.com/topic/149071-solved-get-image-from-url/
Share on other sites

Alternatively, if you can't guarantee that the image will be a JPEG, you can try:

 

// get the contents of the image
$imageData = file_get_contents('http://snapcasa.com/get.aspx?code=4824&size=l&url=www.google.ca');

// create the image resource
$imageResource = imagecreatefromstring($imageData);

// save the image to disk
imagejpeg($imageResource,'image.jpg');

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.