Can anyone help me why unable to upload video and pdf file to the folder?
<?php
$DBConnect = @mysqli_connect("localhost", "root", "")
Or die("<p>Unable to connect to the database server.</p>"
. "<p>Error code " . mysqli_connect_errno()
. ": " . mysqli_connect_error()) . "</p>";
$DBName = "educationtime";
if (!@mysqli_select_db($DBConnect, $DBName))
{
$SQLstring = "CREATE DATABASE $DBName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
mysqli_select_db($DBConnect, $DBName);
}
$TableName = "tutorial";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (!$QueryResult) {
$SQLstring = "CREATE TABLE tutorial
(tutorialID SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
subject VARCHAR(30),
chapter VARCHAR(30),
title VARCHAR(200),
video VARCHAR(200),
file VARCHAR(200),
register_date date,
register_time time)";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to create the member table.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
}
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['video']['name']);
$target = $target . basename( $_FILES['file']['name']);
//This gets all the other information from the form
$subject =$_POST['subject'];
$chapter =$_POST['chapter'];
$title =$_POST['title'];
$video =($_FILES['video']['name']);
$file =($_FILES['file']['name']);
//Writes the information to the database
mysql_query("INSERT INTO tutorial VALUES ( NULL, '$subject', '$chapter', '$title', '$video','$file', now(), now())");
//Writes the photo to the server
if(move_uploaded_file($_FILES['video']['name'], $target) || move_uploaded_file($_FILES['file']['name'], $target ))
{
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
$tutorialID = mysqli_insert_id($DBConnect);
//Tells you if its all ok
echo "<script type='text/javascript'>alert('You have successfully uploaded a new tutorial.');</script><script>window.location = 'FileManager.php'</script>";
}
else {
//Gives and error if its not
echo "<script type='text/javascript'>alert('You have successfully uploaded a new tutorial.');</script><script>window.location = 'FileManager.php'</script>";
}
?>