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

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.