D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
markniuj
/
.vscode-server
/
data
/
User
/
History
/
-7d560aaf
/
Filename :
6Keg.php
back
Copy
<?php include "../config.php"; ?> <?php // Set the character set for the connection $conn->set_charset("utf8mb4"); if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) { $mp4Date = $_POST['mp4Date']; $mp4Category = $_POST['mp4Category']; $mp4Title = $_POST['mp4Title']; $urduText = $_POST['urduText']; $englishText = $_POST['englishText']; $targetDirectory = "uploads/mp4/"; $targetFile = $targetDirectory . basename($_FILES["mp4File"]["name"]); $uploadOk = 1; $fileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); // Check file size for MP4 file if ($_FILES["mp4File"]["size"] > 30 * 1024 * 1024) { echo "Sorry, your MP4 file is too large."; $uploadOk = 0; } // Allow only mp4 file format if ($fileType != "mp4") { echo "Sorry, only MP4 files are allowed."; $uploadOk = 0; } // Thumbnail upload logic $thumbnailDirectory = "uploads/mp4/thumbnails/"; $thumbnailTargetFile = $thumbnailDirectory . basename($_FILES["thumbnail"]["name"]); $thumbnailFileType = strtolower(pathinfo($thumbnailTargetFile, PATHINFO_EXTENSION)); $thumbnailUploadOk = 1; // Check file size for thumbnail image if ($_FILES["thumbnail"]["size"] > 5 * 1024 * 1024) { echo "Sorry, your thumbnail image is too large."; $thumbnailUploadOk = 0; } // Allow only specific image file formats for thumbnails $allowedThumbnailFormats = ["jpg", "jpeg", "png"]; if (!in_array($thumbnailFileType, $allowedThumbnailFormats)) { echo "Sorry, only JPG, JPEG, PNG files are allowed for thumbnails."; $thumbnailUploadOk = 0; } // Upload MP4 file if no errors if ($uploadOk == 1) { if (move_uploaded_file($_FILES["mp4File"]["tmp_name"], $targetFile)) { // MP4 file uploaded successfully // Upload thumbnail if no errors if ($thumbnailUploadOk == 1) { if (move_uploaded_file($_FILES["thumbnail"]["tmp_name"], $thumbnailTargetFile)) { // Thumbnail uploaded successfully $sql = "INSERT INTO mp4 (mp4_name, mp4_date, mp4_category, mp4_title, urdu, english, thumbnail) VALUES ('" . $_FILES["mp4File"]["name"] . "', '$mp4Date', '$mp4Category', '$mp4Title', '$urduText', '$englishText', '" . $_FILES["thumbnail"]["name"] . "')"; if ($conn->query($sql) === TRUE) { echo "The MP4 file " . basename($_FILES["mp4File"]["name"]) . " and thumbnail image have been uploaded and data inserted into the database."; } else { echo "Error inserting data into the database: " . $conn->error; } } else { echo "Sorry, there was an error uploading the thumbnail image."; } } else { echo "Error: " . $thumbnailUploadOk; } } else { echo "Sorry, there was an error uploading your MP4 file."; } } } ?>