convert upload file script to upload url
<p>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.</p>

<p>converting this code to accept remote url upload</p>

<pre><code> &lt;form enctype="multipart/form-data" id="form1" method="post" action=""&gt;

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

<p>

<pre><code> 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;}}
?&gt;
</code></pre>
