D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
mp4-bar
/
Filename :
upload_mp4.php
back
Copy
<?php include '../../config.php'; // Start a session to track upload progress session_start(); 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; } // Set session variables for upload progress $_SESSION['upload_progress'] = 0; // Process file upload with progress tracking if ($uploadOk == 1) { $uploadStartTime = microtime(true); // Start time of upload if (move_uploaded_file($_FILES["mp4File"]["tmp_name"], $targetFile)) { // Get elapsed time to emulate upload progress (for demonstration purposes) $elapsedTime = microtime(true) - $uploadStartTime; // Simulate progress - increase progress every second (adjust as needed) while ($_SESSION['upload_progress'] < 100) { $_SESSION['upload_progress'] += 10; // Simulated progress increase sleep(1); // Simulate processing time (1 second in this example) if ($_SESSION['upload_progress'] > 100) { $_SESSION['upload_progress'] = 100; } } // Insert data into the database after successful upload $sql = "INSERT INTO mp4 (mp4_name, mp4_date, mp4_category, mp4_title, urdu, english) VALUES ('" . $_FILES["mp4File"]["name"] . "', '$mp4Date', '$mp4Category', '$mp4Title', '$urduText', '$englishText')"; if ($conn->query($sql) === TRUE) { echo "The MP4 file " . basename($_FILES["mp4File"]["name"]) . " has been uploaded and data inserted into the database."; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } else { echo "Sorry, there was an error uploading your MP4 file."; } } } ?>