37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
include 'db/config.php';
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$db = db();
|
|
$producto_id = !empty($_POST['producto_id']) ? $_POST['producto_id'] : null;
|
|
$instrucciones = $_POST['instrucciones'] ?? '';
|
|
$foto_path = null;
|
|
|
|
// Manejo de la subida de foto
|
|
if (isset($_FILES['foto_producto']) && $_FILES['foto_producto']['error'] == 0) {
|
|
$target_dir = "assets/uploads/marketing_images/";
|
|
$file_extension = pathinfo($_FILES["foto_producto"]["name"], PATHINFO_EXTENSION);
|
|
$file_name = uniqid() . '.' . $file_extension;
|
|
$target_file = $target_dir . $file_name;
|
|
|
|
if (move_uploaded_file($_FILES["foto_producto"]["tmp_name"], $target_file)) {
|
|
$foto_path = $target_file;
|
|
}
|
|
}
|
|
|
|
try {
|
|
$stmt = $db->prepare("INSERT INTO marketing_videos (producto_id, foto_producto, instrucciones, estado) VALUES (?, ?, ?, 'Pendiente')");
|
|
$stmt->execute([$producto_id, $foto_path, $instrucciones]);
|
|
|
|
header('Location: marketing_produccion.php?success=1');
|
|
} catch (PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
}
|
|
?>
|