<?php
// Check if the file was uploaded
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['file'])) {
    // Set the upload directory
    $uploadDir = 'uploads/';

    // Get the uploaded file
    $file = $_FILES['file'];
    $uploadPath = $uploadDir . basename($file['name']);

    // Move the file to the uploads directory
    if (move_uploaded_file($file['tmp_name'], $uploadPath)) {
        // Success response
        echo json_encode(['message' => 'File uploaded successfully']);
    } else {
        // Error response
        echo json_encode(['message' => 'Failed to upload file']);
    }
} else {
    echo json_encode(['message' => 'No file uploaded']);
}
?>
