Guest User

Untitled

a guest
Mar 7th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(1);
  4. $servername="localhost";
  5. $username="root";
  6. $password="";
  7. $dbname="demo1";
  8. $conn=new mysqli($servername,$username,$password,$dbname);
  9. if ($conn->connect_error) {
  10. die("Connection failed: " . $conn->connect_error);
  11. }
  12.  
  13. extract($_POST);
  14.  
  15. $target_dir = "uploads/";
  16.  
  17. $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  18.  
  19. if($upd)
  20. {
  21. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  22.  
  23. if($imageFileType != "mp4" && $imageFileType != "avi" && $imageFileType != "mov" && $imageFileType != "3gp" && $imageFileType != "mpeg")
  24. {
  25. echo "File Format Not Suppoted";
  26. }
  27.  
  28. else
  29. {
  30.  
  31. $video_path=$_FILES['fileToUpload']['name'];
  32.  
  33. $sql = "INSERT INTO video (path) VALUES('$video_path')";
  34. if ($conn->query($sql) === TRUE) {
  35. echo "New record created successfully";
  36. } else {
  37. echo "Error: " . $sql . "<br>" . $conn->error;
  38. }
  39.  
  40. move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$target_file);
  41.  
  42. echo "uploaded ";
  43.  
  44.  
  45. }
  46.  
  47. }
  48.  
  49. //display all uploaded video
  50.  
  51. if($_POST['disp'])
  52.  
  53. {
  54. // echo "came in";
  55.  
  56. $query=mysqli_query($conn,"select * from video");
  57.  
  58. while($all_video=mysqli_fetch_array($query))
  59.  
  60. {
  61. //echo "test_upload/uploads/".$all_video['path'];
  62.  
  63. ?>
  64.  
  65.  
  66. <h1>test_upload/uploads/<?php echo $all_video['path']; ?></h1>
  67. <video width="300" height="200" controls>
  68. <source src="test_upload/uploads/<?php echo $all_video['path']; ?>" type="video/mp4">
  69. </video>
  70.  
  71.  
  72.  
  73. <?php } } ?>
Add Comment
Please, Sign In to add comment