将上传文件脚本转换为上传网址

i have upload script which does the job for uploading in usual way like browse the file from computer and upload but i want to convert the existing script to upload from url.for example if i paste the url which is direct link of video file it should be uploaded to my server. i can use php copy method and feof to do the job but i want to do with my existing script as several other data are related to my uploading script i tried with above both method but its not working.

converting this code to accept remote url upload

 <form enctype="multipart/form-data" id="form1" method="post" action="">

    <p><label>Upload videos</label>     
    <input type="file" name="video">
            <span>Only mp4 is accepted</span>   
                    <input type="submit" value="Submit" class="button"></p>

 if (!eregi(".mp4$",$_FILES['video']['name'])) {

                 die("Unavailable mp4 format");
    }

    $uri = save_file($_FILES['video'],array('mp4'));        

    function save_file($file) {
 $allowed_ext = array('mp4');



 $ext = $file['name'];

if (in_array($ext, $allowed_ext)) {
die('Sorry, the file type is incorrect:'.$file['name']);
}
$fname = date("H_i",time()).'_'.get_rand(3);
$dir = date("Ym",time());
$folder = 'uploads/userfiles/'.$dir;
 $uri = $folder.'/'.$fname.'.'.$ext;
if (!is_dir($folder))
mkdir($folder, 0777);
if (copy($file['tmp_name'],$uri))
return $uri;
else {
return false;}}
?>

If you're getting a URL, you aren't getting a file upload so you can't just use a file upload script and wish it would work. Just use the copy() function to get the file from the URL and save it to your server.

You should use "http_get" to download files from another server.

$response = http_get($url);