Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit_video']))
  3. {
  4. if($_FILES['FileVideo']['type']!= "video/mp4")
  5. {
  6. die('<script type="text/javascript">window.location.href="upload.php?error=type";</script>');
  7. }
  8. $fileDname=date("Ymdhms");
  9. $ext=pathinfo($_FILES["FileVideo"]["name"],PATHINFO_EXTENSION);
  10. $fullFileName="videos/".$fileDname.".".$ext;
  11. $res=move_uploaded_file($_FILES["FileVideo"]["tmp_name"],$fullFileName );
  12. if(!$res)
  13. {
  14. die('<script type="text/javascript">window.location.href="upload.php?error=upload";</script>');
  15. }else
  16. {
  17. // when file upload success we will add the file to the database
  18. include('config.php');
  19. $con=connect2db();
  20. // read video date
  21. $vTitle=$_POST['txtVideoName'];
  22. $vDesc=$_POST['txtVideoDesc'];
  23. $vCatID=$_POST['CatID'];
  24. $sql = "INSERT INTO `videos` (`Video_ID`, `Title`, `Description`, `FileName`, `Cat_ID`, `Views`, `VLikes`, `DisLikes`, `UploadDateTime`, `Allowed`) VALUES (NULL, '$vTitle', '$vDesc', '$fullFileName', $vCatID, 0, 0, 0, NOW(), 0);";
  25. echo $sql;
  26. $res1=mysqli_query($con,$sql);
  27. mysqli_close($con);
  28. if(!$res1)
  29. {
  30. die('<script type="text/javascript">window.location.href="upload.php?error=sql";</script>');
  31. }
  32. die('<script type="text/javascript">window.location.href="upload.php?error=no";</script>');
  33. }
  34. }
  35. ?>
  36.  
  37. <?php
  38. function connect2db()
  39. {
  40. $host="localhost";
  41. $db_name="abdosoftvideo";
  42. $db_user="root";
  43. $db_pass="";
  44. $con=mysqli_connect($host,$db_name,$db_pass);
  45. if(!$con)
  46. {
  47. die('Cannot connect to database pleace contact administrator!');
  48. }
  49. //mysqli_set_charset($con,'utf8');
  50. mysqli_select_db($con,$db_name);
  51. return($con);
  52. }
  53. ?>
  54.  
  55. DROP TABLE IF EXISTS `videos`;
  56. CREATE TABLE `videos` (
  57. `Video_ID` int(11) NOT NULL AUTO_INCREMENT,
  58. `Title` varchar(100) DEFAULT NULL,
  59. `Description` text,
  60. `FileName` varchar(255) DEFAULT NULL,
  61. `Cat_ID` int(11) DEFAULT NULL,
  62. `Views` int(11) DEFAULT NULL,
  63. `VLikes` int(11) DEFAULT NULL,
  64. `DisLikes` int(11) DEFAULT NULL,
  65. `UploadDateTime` datetime DEFAULT NULL,
  66. `Allowed` int(11) DEFAULT NULL,
  67. PRIMARY KEY (`Video_ID`)
  68. ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement