-
Notifications
You must be signed in to change notification settings - Fork 0
/
video1.php
36 lines (27 loc) · 1.05 KB
/
video1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
if (isset($_POST['submit']) && isset($_FILES['my_video'])) {
include "videoconn.php";
$video_name = $_FILES['my_video']['name'];
$tmp_name = $_FILES['my_video']['tmp_name'];
$error = $_FILES['my_video']['error'];
if ($error === 0) {
$video_ex = pathinfo($video_name, PATHINFO_EXTENSION);
$video_ex_lc = strtolower($video_ex);
$allowed_exs = array("mp4", 'webm', 'avi', 'flv');
if (in_array($video_ex_lc, $allowed_exs)) {
$new_video_name = uniqid("video-", true). '.'.$video_ex_lc;
$video_upload_path = 'uploads/'.$new_video_name;
move_uploaded_file($tmp_name, $video_upload_path);
// Now let's Insert the video path into database
$sql = "INSERT INTO videos(video_url)
VALUES('$new_video_name')";
mysqli_query($conn, $sql);
header("Location: viewvideo.php");
}else {
$em = "You can't upload files of this type";
header("Location: uploadvideo.php?error=$em");
}
}
}else{
header("Location: uploadvideo.php");
}