<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FTP Upload Tool</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #121212;
        }
        .upload-box {
            background: #333;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 16px rgba(0,0,0,0.3);
            width: 300px;
            text-align: center;
            transition: transform 0.3s ease-in-out;
        }
        .upload-box:hover {
            transform: scale(1.05);
        }
        .drag-area {
            border: 2px dashed #007BFF;
            padding: 30px;
            text-align: center;
            color: #fff;
            margin: 10px 0;
        }
        .drag-area.dragging {
            background-color: rgba(0,123,255,0.3);
        }
        input[type="text"], input[type="password"] {
            width: 100%;
            padding: 8px;
            margin: 10px 0;
            box-sizing: border-box;
            border-radius: 4px;
            border: 1px solid #777;
            background-color: #222;
            color: #eee;
        }
        button {
            background-color: #007BFF;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.2s ease-in-out;
        }
        button:hover {
            background-color: #0056b3;
        }
        ul {
            list-style: none;
            padding: 0;
        }
        li {
            background: #444;
            margin-top: 5px;
            padding: 5px;
            border-radius: 4px;
            color: #ddd;
        }
    </style>
</head>
<body>
    <div class="upload-box">
        <h1>FTP Upload Tool</h1>
        <form action="/upload" method="post" enctype="multipart/form-data">
            <input type="text" name="host" placeholder="FTP Host" required><br>
            <input type="text" name="username" placeholder="Username" required><br>
            <input type="password" name="password" placeholder="Password" required><br>
            <input type="text" name="remoteDir" placeholder="Remote Directory" required><br>
            <div class="drag-area" id="drop-area">
                Drag & Drop Files Here<br>
                <input type="file" name="file" required hidden multiple>
            </div>
            <ul id="file-list"></ul>
            <button type="submit">Upload File(s)</button>
        </form>
    </div>

    <script>
        const dropArea = document.getElementById('drop-area');
        const fileInput = dropArea.querySelector('input[type="file"]');
        const fileList = document.getElementById('file-list');

        ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
            dropArea.addEventListener(eventName, preventDefaults, false);
        });

        function preventDefaults(e) {
            e.preventDefault();
            e.stopPropagation();
        }

        ['dragenter', 'dragover'].forEach(eventName => {
            dropArea.addEventListener(eventName, highlight, false);
        });

        ['dragleave', 'drop'].forEach(eventName => {
            dropArea.addEventListener(eventName, unhighlight, false);
        });

        function highlight() {
            dropArea.classList.add('dragging');
        }

        function unhighlight() {
            dropArea.classList.remove('dragging');
        }

        dropArea.addEventListener('drop', handleDrop, false);

        function handleDrop(e) {
            const dt = e.dataTransfer;
            const files = dt.files;
            fileInput.files = files;
            updateFileList(files);
        }

        fileInput.addEventListener('change', () => {
            updateFileList(fileInput.files);
        });

        function updateFileList(files) {
            fileList.innerHTML = '';
            Array.from(files).forEach(file => {
                const li = document.createElement('li');
                li.textContent = file.name;
                fileList.appendChild(li);
            });
        }
    </script>
</body>
</html>
