Company Information Entry
'/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)) {
echo "$input_name uploaded successfully.
";
} else {
$errors[] = "Failed to upload $input_name. Check folder permissions.";
}
}
}
}
// Save text data to JSON
$text_fields = [
'channel_name', 'office_address', 'contact_details', 'enforcement_officer',
'eo_contact_details', 'company_name', 'cin_number', 'gstin_number'
];
$data_to_save = [];
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!
";
// Refresh to show updated data in form
echo "";
} else {
$errors[] = "Failed to save JSON data. Check folder permissions.";
}
}
if (!empty($errors)) {
foreach ($errors as $error) {
echo "$error
";
}
}
}
?>