Jump to content

Grab png image remotely without CURL


maccy93

Recommended Posts

I need to get images from a site remotely. I own and control the site I am getting trying to get the files from.

 

I tried the following:

//write the new file to disk
$fh = fopen($fileLocationHost, 'w') or 

//get the contents of the file from the 2spring server according to the coordinates
$newImage = file_get_contents('http://www.mysite.co.uk/'.$imageLocation.'/'.$imageName);

//write the changes
fwrite($fh, $newImage);

//close the files
fclose($fh);

 

It worked... kind of. It downloaded something but the png image was unreadable.

 

I then found this link: http://www.edmondscommerce.co.uk/php/php-save-images-using-curl/  which talks about a problem with allow_url_fopen and uses CURL to grab images from another site... however I cannot use CURL as it is disabled.

 

Is there a way of writing an image to a server another way? Is there a way of doing this via fopen?

 

Any help would be very much appreciated :)

 

(I also cannot use fsockopen either as this is also disabled)

Link to comment
https://forums.phpfreaks.com/topic/254901-grab-png-image-remotely-without-curl/
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.