Click here to Skip to main content

sidduhedginal 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title> Upload Image </title>
    <?php
    // if something was posted, start the process...
    if(isset($_POST['upload']))
    {
    
    
    
    // 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
            if(!get_magic_quotes_gpc()){
            $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);
            fclose($extract);
    
    
    
         if(!empty($_FILES))
        {
            $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 "===========";
    
            $ok=1;
            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.";
             }
        }
    
    
    
    mysql_close();
    
    echo "Successfully uploaded your picture!";
    }else{die("No uploaded file present");
    }
    
    
    
    ?>
Tags: PHP

Preview



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.
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 | Mobile
Web02 | 2.8.140916.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
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