'/var/www/html/app_ad.png',
'app_logo' => '/var/www/html/app_logo.png'
];
$errors = [];
foreach ($upload_paths as $input_name => $destination) {
if (isset($_FILES[$input_name]) && $_FILES[$input_name]['error'] == 0) {
$ext = pathinfo($_FILES[$input_name]['name'], PATHINFO_EXTENSION);
if (strtolower($ext) !== 'png') {
$errors[] = "File for $input_name must be a PNG.";
} else {
if (move_uploaded_file($_FILES[$input_name]['tmp_name'], $destination)) {
// Success
} else {
$errors[] = "Failed to upload $input_name.";
}
}
}
}
$text_fields = [
'channel_name', 'office_address', 'contact_details', 'enforcement_officer',
'eo_contact_details', 'company_name', 'cin_number', 'gstin_number'
];
$data_to_save = [];
foreach ($text_for_save as $field) { // Note: fixed variable name from previous logic
// ... (logic remains same)
}
// Re-implementing the logic correctly for the snippet
foreach ($text_fields as $field) {
$data_to_save[$field] = $_POST[$field] ?? '';
}
if (empty($errors)) {
if (file_put_contents($json_file, json_encode($data_to_save, JSON_PRETTY_PRINT))) {
echo '
All data and files processed successfully!
';
echo "";
} else {
$errors[] = "Failed to save JSON data.";
}
}
if (!empty($errors)) {
foreach ($errors as $error) {
echo "
$error
";
}
}
}
?>