29 lines
948 B
PHP
29 lines
948 B
PHP
<?php
|
|
include 'db/config.php';
|
|
$db = db();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$nombre = $_POST['nombre'] ?? '';
|
|
$categoria = $_POST['categoria'] ?? 'Otros';
|
|
|
|
if (isset($_FILES['archivo']) && $_FILES['archivo']['error'] == 0) {
|
|
$uploadDir = 'assets/uploads/marketing_assets/';
|
|
if (!is_dir($uploadDir)) {
|
|
mkdir($uploadDir, 0777, true);
|
|
}
|
|
|
|
$fileName = time() . '_' . basename($_FILES['archivo']['name']);
|
|
$targetPath = $uploadDir . $fileName;
|
|
|
|
if (move_uploaded_file($_FILES['archivo']['tmp_name'], $targetPath)) {
|
|
$stmt = $db->prepare("INSERT INTO marketing_assets (nombre, categoria, archivo_path) VALUES (?, ?, ?)");
|
|
$stmt->execute([$nombre, $categoria, $targetPath]);
|
|
|
|
header("Location: marketing_assets.php?success=1");
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
header("Location: marketing_assets.php?error=1");
|
|
exit; |