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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.