sameer kumar
sameer kumar

Reputation: 149

Video not uploading to mysql database.Wheather the image and audio insert at the same video file field

Here is my code for upload video but the video neither going to the folder nor to the database. But at the same video file field if You upload image or audio it's working and also i set the upload_max_filesize to 500M in php.ini. can any one suggest thank you in advance.

this is the code which i use to upload video.

<?php
mysql_connect("localhost","root","");
mysql_select_db("test");

if(isset($_POST['submit']))
{     
        $id=$_POST['id'];
        $video=$_FILES['vid']['name'];
        $type=$_FILES['vid']['type'];
        $size=$_FILES['vid']['size'];
        $tempname=$_FILES['vid']['tmp_name'];
        $dir="uploadvideo/".$video;
        move_uploaded_file($tempname,"$dir");
$insert=mysql_query("insert into myblog(`video`) values ('$video')")or die(mysql_error());
      if($insert)     
      {
          echo "<script>alert('Inserted Succesful')</script>";


     }

}
?>

<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="" method="post" enctype="multipart/form-data">

<label for="file" class="tbl">Filename:</label>
<input type="file" name="vid" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>


</body>
</html>

Upvotes: 0

Views: 570

Answers (2)

mizan3008
mizan3008

Reputation: 379

<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";


$conn = new mysqli($servername, $username, $password, $dbname);


if ($conn->connect_error) {
    die("Database connection failed: " . $conn->connect_error);
}

if(isset($_POST['submit']))
{     
    $id=$_POST['id'];
    $video=$_FILES['vid']['name'];
    $type=$_FILES['vid']['type'];
    $size=$_FILES['vid']['size'];
    $tempname=$_FILES['vid']['tmp_name'];
    $dir="uploadvideo/".$video;
    move_uploaded_file($tempname,"$dir");
    $sql = "INSERT INTO myblog (`video`) VALUES ('".$video."')";
    $result = mysqli_query($conn, $sql);

    if($result)     
    {
        echo "<script>alert('Inserted Succesful')</script>";
    }
}

Upvotes: 0

talkhabi
talkhabi

Reputation: 2759

in your php.ini

Find:

post_max_size = 8M

upload_max_filesize = 2M

max_execution_time = 30

max_input_time = 60

memory_limit = 8M

Change to:

post_max_size = 750M

upload_max_filesize = 750M

max_execution_time = 5000

max_input_time = 5000

memory_limit = 1000M

Upvotes: 1

Related Questions