View Full Version : how do you copy an external file URL to your own server?

02-28-2008, 07:28 PM
I am trying to copy an image that the user inputs to a local copy on my server.. and for security reasons rename the file

my form var is: $fileURL

is this the way to go about doing it or is this potentially a security threat? is there a better way?

$destination = '/www/myserver/images/uploaded/';
$newname = md5(rand(1,1000));
copy($fileURL, $destination);
$filename = not sure how to get the filename from $fileURL
rename($filename, $newname);

Daniel Israel
02-28-2008, 07:48 PM
That's the way I normally do it. The other option would be to not let the person enter a URL, but have a input field of FILE.