Jump to content

[SOLVED] Copy images from another website?


bpops

Recommended Posts

I would like to have a form such as this:

 

Image URL:  [________________________]  [_Submit_]

 

that when clicked, takes the image from (any) url and saves a copy in a specified directory.

 

I have found many tutorials on UPLOADING images, but I can't find information on how to grab one from a URL. Can anyone quickly point me to a function or tutorial? Thanks in advance for your help!

Link to comment
https://forums.phpfreaks.com/topic/88933-solved-copy-images-from-another-website/
Share on other sites

Well I think I finally figured out one way of doing it. It works perfectly, and it's very little code:

 

Given the url ($url) and desired filename ($filename):

 

$im = @imagecreatefromjpeg($url);
      
if($im){
        
   imagejpeg($im, $filename);

}

 

There might be a better way of doing it, but I'm happy with this. If anyone else has any comments, feel free to ad them, but I'll go ahead and mark this solved.

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.