Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(1);
- $servername="localhost";
- $username="root";
- $password="";
- $dbname="demo1";
- $conn=new mysqli($servername,$username,$password,$dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- extract($_POST);
- $target_dir = "uploads/";
- $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
- if($upd)
- {
- $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
- if($imageFileType != "mp4" && $imageFileType != "avi" && $imageFileType != "mov" && $imageFileType != "3gp" && $imageFileType != "mpeg")
- {
- echo "File Format Not Suppoted";
- }
- else
- {
- $video_path=$_FILES['fileToUpload']['name'];
- $sql = "INSERT INTO video (path) VALUES('$video_path')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$target_file);
- echo "uploaded ";
- }
- }
- //display all uploaded video
- if($_POST['disp'])
- {
- // echo "came in";
- $query=mysqli_query($conn,"select * from video");
- while($all_video=mysqli_fetch_array($query))
- {
- //echo "test_upload/uploads/".$all_video['path'];
- ?>
- <h1>test_upload/uploads/<?php echo $all_video['path']; ?></h1>
- <video width="300" height="200" controls>
- <source src="test_upload/uploads/<?php echo $all_video['path']; ?>" type="video/mp4">
- </video>
- <?php } } ?>
Add Comment
Please, Sign In to add comment