Click here to Skip to main content
13,558,882 members

how to upload videos to directory in php using mysql database

sidduhediginal asked:

Open original thread
hi everyone,

I am siddu here and am new to PHP, I have given code here which is used to upload video but not more than 4MB. So can you please help me out.

Thanks in advance
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title> Upload Image </title>
    // if something was posted, start the process...
    // connect to the database
    include "connect1.php";
    mysql_connect("$host", "$user", "$pass")
         or die("Could not connect: " . mysql_error());
         // select our database
         mysql_select_db("$db") or die(mysql_error());
            // the query that will add this to the database
            // define the posted file into variables
            echo $name = $_FILES['picture']['name'];
            echo $tmp_name = $_FILES['picture']['tmp_name'];
            echo $type = $_FILES['picture']['type'];
            echo $size = $_FILES['picture']['size'];
            // if your server has magic quotes turned off, add slashes manually
            $name = addslashes($name);
            // open up the file and extract the data/content from it
            $extract = fopen($tmp_name, 'r');
            $content = fread($extract, $size);
            $content = addslashes($content);
            $target = "D:/videos/";
             $target = $target . basename( $_FILES['picture']['name']) ;
             echo $target;
            $addfile = "INSERT INTO video VALUES ('','$name', '$size', '$type','$target')";
            mysql_query($addfile) or die(mysql_error());
            echo "===========";
            echo $target;
            echo "===========";
            if(move_uploaded_file($_FILES['picture']['tmp_name'], $target))
             echo "The file ". basename( $_FILES['picture']['name']). " has been uploaded <br/>";
             else {
             echo "Sorry, there was a problem uploading your file.";
    echo "Successfully uploaded your picture!";
    }else{die("No uploaded file present");
     <div align="center">
        <br />
        <a href="file.html">upload more images</a>
Tags: PHP


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy |
Web02 | 2.8.180515.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100