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?
how to copy an image URL from a form to your own server??
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: how to copy an image URL from a form to your own server??
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
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??
my host doesn't allow me to use fopen() so I cant use your solution
any other ideas?
any other ideas?
- Sekka
- Forum Commoner
- Posts: 91
- Joined: Mon Feb 18, 2008 10:25 am
- Location: Huddersfield, West Yorkshire, UK
Re: how to copy an image URL from a form to your own server??
I have just been talking about this in another thread.
From what I understand, fopen() is the only way to do this.
From what I understand, fopen() is the only way to do this.