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;}}
?>