This commit is contained in:
Francesco Picone
2025-12-06 18:50:57 +01:00
parent 86f4774df2
commit ca86649914
8 changed files with 219 additions and 2 deletions

View File

@@ -65,6 +65,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($type === 'video' && $video_platform === 'local' && isset($_FILES['video_file']) && $_FILES['video_file']['error'] === UPLOAD_ERR_OK) {
$upload_dir = $is_demo ? '../uploads/lessons/demo/' : '../uploads/lessons/pay/';
// Crea le cartelle se non esistono
if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0755, true);
}
// Crea nome file sicuro
$file_extension = strtolower(pathinfo($_FILES['video_file']['name'], PATHINFO_EXTENSION));
$allowed_extensions = ['mp4', 'webm', 'ogg', 'mov'];
@@ -82,6 +87,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
// Imposta il nuovo percorso
$video_url = '/uploads/lessons/' . ($is_demo ? 'demo' : 'pay') . '/' . $file_name;
// Estrai durata automaticamente se non specificata
if (empty($duration)) {
$duration = get_video_duration($upload_path);
}
} else {
$error = 'Errore durante il caricamento del file';
}