40097-vm/delete_marketing_asset.php
2026-05-05 03:03:33 +00:00

24 lines
615 B
PHP

<?php
include 'db/config.php';
$db = db();
if (isset($_GET['id'])) {
$id = $_GET['id'];
// Obtener la ruta del archivo para borrarlo del servidor
$stmt = $db->prepare("SELECT archivo_path FROM marketing_assets WHERE id = ?");
$stmt->execute([$id]);
$asset = $stmt->fetch(PDO::FETCH_ASSOC);
if ($asset) {
if (file_exists($asset['archivo_path'])) {
unlink($asset['archivo_path']);
}
$stmt = $db->prepare("DELETE FROM marketing_assets WHERE id = ?");
$stmt->execute([$id]);
}
}
header("Location: marketing_assets.php");
exit;