<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_FILES['test_file'])) {
        $upload_dir = __DIR__ . '/uploads/test/';
        if (!is_dir($upload_dir)) {
            mkdir($upload_dir, 0777, true);
        }
        $target_file = $upload_dir . basename($_FILES['test_file']['name']);
        if (move_uploaded_file($_FILES['test_file']['tmp_name'], $target_file)) {
            echo "File uploaded successfully: " . htmlspecialchars(basename($_FILES['test_file']['name']));
        } else {
            echo "Failed to upload file.";
        }
    } else {
        echo "No file uploaded.";
    }
} else {
?>
<form method="post" enctype="multipart/form-data">
    <label for="test_file">Select file to upload:</label>
    <input type="file" name="test_file" id="test_file" required>
    <button type="submit">Upload</button>
</form>
<?php
}
?>
