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>";
 } 
 ?>
diafol commented: Use [ CODE ] tags -3

Recommended Answers

All 2 Replies

I dont think you can save the vid or pdf files to the database. You need to link to the document, but put the name of the file in the database. Then echo it through an anchor. Is the file being transfered? Try it with a pic too

Check size limitations too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.