44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['banner_image_xpress'])) {
|
|
$target_dir = "assets/uploads/";
|
|
$target_file = $target_dir . "cobertura_xpress_banner.jpg";
|
|
$uploadOk = 1;
|
|
$imageFileType = strtolower(pathinfo($_FILES["banner_image_xpress"]["name"], PATHINFO_EXTENSION));
|
|
|
|
// Check if image file is a actual image or fake image
|
|
$check = getimagesize($_FILES["banner_image_xpress"]["tmp_name"]);
|
|
if ($check !== false) {
|
|
$uploadOk = 1;
|
|
} else {
|
|
$_SESSION['error_message'] = "El archivo no es una imagen.";
|
|
$uploadOk = 0;
|
|
}
|
|
|
|
// Allow certain file formats
|
|
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
|
|
&& $imageFileType != "gif" && $imageFileType != "webp") {
|
|
$_SESSION['error_message'] = "Solo se permiten archivos JPG, JPEG, PNG, WEBP y GIF.";
|
|
$uploadOk = 0;
|
|
}
|
|
|
|
if ($uploadOk == 1) {
|
|
if (move_uploaded_file($_FILES["banner_image_xpress"]["tmp_name"], $target_file)) {
|
|
$_SESSION['success_message'] = "La imagen de cabecera de Cobertura Xpress ha sido actualizada.";
|
|
} else {
|
|
$_SESSION['error_message'] = "Hubo un error al subir tu archivo.";
|
|
}
|
|
}
|
|
} else {
|
|
$_SESSION['error_message'] = "No se recibió ningún archivo para Cobertura Xpress.";
|
|
}
|
|
|
|
header("Location: configuracion.php");
|
|
exit;
|
|
?>
|