<?php
if(isset($_FILES['image']))
{
$errors= array();
$file_name = $_FILES['image']['name'];
$file_tmp =$_FILES['image']['tmp_name'];
if(empty($errors)==true)
{
$path="videos/".$file_name;
move_uploaded_file($file_tmp,$path);
$server = "localhost";
$user_name = "******"; //database name
$password = "******"; //database password
$database = "sample";
$connection = mysqli_connect("$server","$user_name","$password","$database") or die("Error " . mysqli_error($connection));
$sql ="insert into video(location) values('$path')"; $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
echo "Success";
}
else
{
print_r($errors);
}
}
?>
<html>
<body>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
Note:
Give 777 Permission to the folder in which videos are being uploaded else you may get an error
Comments
Post a Comment