Page 1 of 1

how to copy an image URL from a form to your own server??

Posted: Fri Feb 29, 2008 11:46 pm
by bobafart
I am trying to copy an image that the user inputs into a form to a local copy on my server.. and for security reasons rename the file

so basically, user inputs a URL to the image (http://www.foo.com/image.gif)
user hits submit
script copies http://www.foo.com/image.gif and renames it to a random md5 name

how would I do this using PHP?

Re: how to copy an image URL from a form to your own server??

Posted: Sat Mar 01, 2008 12:25 am
by Kieran Huggins
use http://php.net/file_get_contents to grab the file.

also, why not name the file it's own md5() instead of a random one? That way you get the added benefit of saving storage space when there's a collision ;-)

Re: how to copy an image URL from a form to your own server??

Posted: Sat Mar 01, 2008 9:50 am
by bobafart
my host doesn't allow me to use fopen() so I cant use your solution

any other ideas?

Re: how to copy an image URL from a form to your own server??

Posted: Sat Mar 01, 2008 1:10 pm
by Sekka
I have just been talking about this in another thread.

From what I understand, fopen() is the only way to do this.