From 2b150db94d9db0bf2b25e927b307c06e4ddf063f Mon Sep 17 00:00:00 2001 From: Devdatt Bhatt Date: Wed, 20 May 2026 12:05:06 +0000 Subject: [PATCH] update --- encoder/app.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/encoder/app.php b/encoder/app.php index f8975f3..a10f3fa 100644 --- a/encoder/app.php +++ b/encoder/app.php @@ -14,10 +14,11 @@ $error_message = ''; // --- 1. Handle Form Submission BEFORE any HTML is sent --- if (isset($_POST['submit'])) { $upload_paths = [ - 'app_und' => '/var/www/html/app_ad.png', // Note: I noticed a potential mismatch in your logic, but keeping your structure + 'app_und' => '/var/www/html/app_ad.png', 'app_ad' => '/var/www/html/app_ad.png', 'app_logo' => '/var/www/html/app_logo.png' ]; + $secondary_dir = '/var/www/encoder/'; $errors = []; @@ -28,7 +29,16 @@ if (isset($_POST['submit'])) { if (strtolower($ext) !== 'png') { $errors[] = "File for $input_name must be a PNG."; } else { - if (!move_uploaded_file($_FILES[$input_name]['tmp_name'], $destination)) { + // Move to primary destination (/var/www/html/) + if (move_uploaded_file($_FILES[$input_name]['tmp_name'], $destination)) { + // Create a copy in the encoder directory (/var/www/encoder/) + $filename = basename($destination); + $secondary_destination = $secondary_dir . $filename; + + if (!copy($destination, $secondary_destination)) { + $errors[] = "Failed to create secondary copy for $input_name in encoder folder."; + } + } else { $errors[] = "Failed to upload $input_name."; } } @@ -57,6 +67,7 @@ if (isset($_POST['submit'])) { file_put_contents($json_file, json_encode($data_to_save, JSON_PRETTY_PRINT)); // Redirect to the same page to refresh the data and clear POST state + header("cap_url: " . $_SERVER['PHP_SELF']); header("Location: " . $_SERVER['PHP_SELF']); exit; } else { @@ -86,7 +97,7 @@ include 'header.php';

Company Information Entry

-
+
@@ -131,8 +142,8 @@ include 'header.php';

Upload Ad (PNG)

- -
Current:
+ +
Current:
@@ -141,8 +152,8 @@ include 'header.php';

Upload Logo (PNG)

- -
Current:
+ +
Current: