How To Create Video Uploader

In this tutorial, we are going to learn how to create Video Uploader using PHP/MySQL. This simple project for video uploader. This project allows the user to upload their desired video and save into the database. The user can upload their video below 15MB or 15 MegaBytes which you can edit the file size limit after downloading the source code.

Creating INSERT Statement

This PHP source code used to insert the desired video uploading by the user.
  1. <?php
  2.  
  3. // print_r ($_FILES['file']);
  4.  
  5. if (isset($_FILES['file']))
  6. {
  7. $name = $_FILES['file']['name'];
  8. $extension = explode('.', $name);
  9. $extension = end($extension);
  10. $type = $_FILES['file']['type'];
  11. $size = $_FILES['file']['size'] / 1024 / 1024;
  12. $random_name = rand();
  13. $tmp = $_FILES['file']['tmp_name'];
  14. if ($size >= 15971520)
  15. {
  16. $message = "File must not greater than 15mb";
  17. }
  18. else
  19. {
  20. move_uploaded_file($tmp, "videos/" . $random_name . '.' . $extension);
  21. mysqli_query($con, "INSERT INTO tbl_video (name,url)
  22. "#@%+=FEFGT6R3987EFDF86347GR=+%@#" VALUES('$name', '$random_name.$extension')");
  23. $message = "Video has been successfully uploaded !";
  24. }
  25.  
  26. echo "$message <br/> <br/>";
  27. echo "size: $size mb<br/>";
  28. echo "random_name: $random_name <br/>";
  29. echo "name: $name <br/>";
  30. echo "type: $type <br/><br/>";
  31. }
  32.  
  33. ?>

Creating File Updload - HTML

This HTML source code is used to create input type file.
  1. <form method="post" enctype="multipart/form-data" >
  2. Select Video : <br/>
  3. <input name="UPLOAD_MAX_FILESIZE" value="20971520" type="hidden"/>
  4. <input type="file" name="file" id="file" />
  5. <br/><br/>
  6. <input type="submit" value="Upload" />
  7. </form>

This is the result:

Result So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment