D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
upload_audio.php
back
Copy
<?php include "../config.php"; ?> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { $audio_filename = $image_filename = $urdu_title = $english_title = $a_date = $details = $category = $speaker = ''; // Handle audio file upload if (isset($_FILES['audio']) && $_FILES['audio']['error'] === UPLOAD_ERR_OK) { $audio_filename = $_FILES['audio']['name']; $audio_tmp_path = $_FILES['audio']['tmp_name']; $audio_destination = 'uploads/audio/' . $audio_filename; if (move_uploaded_file($audio_tmp_path, $audio_destination)) { // Audio file has been successfully moved } else { die('Error moving audio file.'); } } else { die('Error uploading audio file.'); } // Handle image file upload if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) { $image_filename = $_FILES['image']['name']; $image_tmp_path = $_FILES['image']['tmp_name']; $image_destination = 'uploads/images/' . $image_filename; if (move_uploaded_file($image_tmp_path, $image_destination)) { // Image file has been successfully moved } else { die('Error moving image file.'); } } else { die('Error uploading image file.'); } // Retrieve other form fields $urdu_title = $_POST['urdu_title']; $english_title = $_POST['english_title']; $a_date = $_POST['a_date']; $details = $_POST['details']; $category = $_POST['category']; $speaker = $_POST['speaker']; // Now, insert data into the database $query = "INSERT INTO audio_files (audio_filename, image_filename, urdu_title, english_title, a_date, details, category, speaker) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; $stmt = $conn->prepare($query); $stmt->bind_param("ssssssss", $audio_filename, $image_filename, $urdu_title, $english_title, $a_date, $details, $category, $speaker); if ($stmt->execute()) { header("Location: dashboard.php"); exit(); // Add exit after header redirection } else { echo "Error: " . $stmt->error; } $stmt->close(); } ?>