Hi I created some codes to upload my videos on the website, but for some reason it stopped working.
Can Someone please help me debug the issues thanks!
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$database = "name_of_database";
$db = mysql_connect($hostname, $username, $password);
mysql_select_db($database, $db);
$path = "videos/";
//check to see if directory already exist
if(!file_exists($path))
{
//creating directory
mkdir($path, 0777);
$path = $path;
}
else
{
$path = $path;
}
$filename = $_FILES['videofile']['name']; //Find the Extension so I can change the file name
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts($_FILES['videofile']['name']);
$rand = rand ();
$ran = 'vid_'.$rand;
$ran2 = $ran.'.';
$target = 'videos/';//File Location
$target = $target.$ran2.$ext;
$location = $path.$ran2.$ext;
if(move_uploaded_file($_FILES['videofile']['tmp_name'], $target)) {
mysql_query("INSERT INTO video (video_link) VALUES ('$location')");
header("Location:video.php?w=ok&f=".$location);
} else{
header("Location:video.php?error=1");
echo "Error when uploading the video.";
}
?>
For some reason it keeps going to the Else statement verses the "If".
Thank you in advance