-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-videos.inc.php
36 lines (33 loc) · 1.46 KB
/
add-videos.inc.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['file'])) {
$teacherUid = $_POST['teacherUid'];
$teacherId = $_POST['teacherId'];
$videoTitle = $_POST["videoTitle"];
$videoStatus = $_POST["videoStatus"];
$servicesTitle = $_POST['servicesTitle'];
$videoDiscription = $_POST["videoDiscription"];
$videoFileName = $_FILES['file']['name'];
$videoFileType = $_FILES['file']['type'];
$videoTempName = $_FILES['file']['tmp_name'];
$videoFileSize = $_FILES['file']['size'];
$videoFileDestination = pathinfo($videoFileName, PATHINFO_EXTENSION);
$videoFileDestinationLowercase = strtolower($videoFileDestination);
$allowedVideoType = array('mp4');
$code = explode('-', $servicesTitle);
$servicesId = $code[0];
$servicesTitle = $code[1];
require_once 'dbh.inc.php';
require_once 'functions.inc.php';
if (in_array($videoFileDestinationLowercase, $allowedVideoType)) {
$newVideoName = uniqid("video-", true) . '.' . $videoFileDestinationLowercase;
$videoUploadPath = "../../upload/" . $newVideoName;
move_uploaded_file($videoTempName, $videoUploadPath);
addVideos($conn, $newVideoName, $servicesTitle, $videoTitle, $videoDiscription, $videoStatus, $teacherUid, $servicesId, $teacherId);
} else {
header("location: ../add-videos.php?error=videoformat");
exit();
}
} else {
header("location: ../add-videos.php");
exit();
}