# Upload a file from web url using PHP?



## DrP (Jul 23, 2005)

Hi,
I have a form where the user browses to a file using . I then use the following script to upload the file and change its name to match the entry in MySql:

move_uploaded_file($_FILES['reviews_imagename']['tmp_name'], $filename);
$newimagename = "userimages/" . $lastpicid . ".jpg";
rename($filename, $newimagename);
$addfile = "UPDATE reviews SET imagename = '$newimagename' WHERE id = $lastpicid";
$addfile_results = mysql_query($addfile) or die(mysql_error());

What I'm after is adding the option for the user to paste the url of an image into the form and then the script upload that image. How would I go about this?
Thanks,


----------



## brendandonhu (Jul 8, 2002)

Use copy() to save the remote image to your server.


----------

