PHP simple video upload function -
i trying create php video upload function, can't work. no errors, doesn't upload file. have checked if max file size in phpinfo(), isn't. limit set 64m.
the paths should correct, have triple checked everything. have followed guides, still nothing.
<form action='' method='post' enctype='multipart/form-data'> <?php if(isset($_files['video'])){ $name = $_files['video']['name']; $type = explode('.', $name); $type = end($type); $size = $_files['video']['size']; $random_name = rand(); $tmp = $_files['video']['tmp_name']; if($type != 'mp4' && $type != 'mp4' && $type != 'mkv'){ $message = "format not supported!!"; } else { move_uploaded_file($tmp, 'videos/'.$name.'.'.$type); $message = "successfully uploaded!"; } echo "$message"; } ?> select video: <br> <input type='file' name='video' /><br> <input class='btn' type='submit' value='upload'> </form>
there bug in line,
move_uploaded_file($tmp, 'videos/'.$name.'.'.$type);
change to
$dotpos=strpos($name,'.'); move_uploaded_file($tmp, 'videos/'.substr($name,0,$dotpos).'.'.$type);
Comments
Post a Comment