How to upload video using PHP and MySQL Database?

Today, We want to share with you how to upload video in php.In this post we will show you video uploads in php, hear for Upload and Display Video in PHP & Check extension of video before uploading the video file. we will give you demo and example for implement.In this post, we will learn about Upload Video Files Images Using PHP Mysql with an example.

Upload and Store video to MySQL Database with PHP

If video file or format extension is mp4,avi,mov,3gp,mpeg then uploads the reference of video file in MySQL Database Table. Also, show how you can display stored videos in the database.

uploads video in php, upload video in php mysql, how to display video in php from database, multiple video uploads in php, how to insert mp4 video in php, file uploads in php, file uploads in php mysql database, video upload using ajax in php,
uploads video in php

Create Database and Table

step 1:

//create a database tiktok_tools
CREATE DATABASE `tiktok_tools`;
USE tiktok_tools;

//create a table textarea
CREATE TABLE `video`
 (
`v_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`video_name` varchar(255) not null 
)

step 2: PHP Script


	 
	  
	

HTML Form for Video uploading

step 3:

Upload Video

Example 2: Upload and Store video to MySQL Database with PHP

Table structure

Step 1: videos table in the example.

CREATE TABLE `videos` (
  `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `vdo_address` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Configuration

Step 2: Create a config.php file


Upload and Store Video

step 3:

= $maxsize) || ($_FILES["file"]["size"] == 0)) {
             $_SESSION['message'] = "File too large. File must be less than 5MB.";
          }else{
             // Upload
             if(move_uploaded_file($_FILES['file']['tmp_name'],$target_file)){
               // Insert record
               $query = "INSERT INTO videos(name,vdo_address) VALUES('".$name."','".$target_file."')";

               mysqli_query($con,$query);
               $_SESSION['message'] = "Upload successfully.";
             }
          }

       }else{
          $_SESSION['message'] = "Invalid file extension.";
       }
   }else{
       $_SESSION['message'] = "Please select a file.";
   }
   header('location: index.php');
   exit;
} 
?>
 
 
  
     Upload and Store video to MySQL Database with PHP
  
  

    
    
    

Read Videos

step 4: Create readfile.php file




  
    Upload and Store video to MySQL Database with PHP - www.pakainfo.com
  
  
    

".$name."
"; } ?>

I hope you get an idea about uploads video in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment