<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['image'])) {
    $target = __DIR__ . '/Gemini_Generated_Image_jcybz9jcybz9jcyb.png';
    if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
        $msg = "<p style='color: green; font-weight: bold;'>อัปโหลดสำเร็จแล้ว! กรุณากลับไปที่หน้าแรกแล้วกด F5 เพื่อดูรูปภาพ</p>";
    } else {
        $msg = "<p style='color: red; font-weight: bold;'>เกิดข้อผิดพลาดในการอัปโหลด</p>";
    }
}
?>
<!DOCTYPE html>
<html lang="th">
<head>
    <meta charset="UTF-8">
    <title>อัปโหลดรูปภาพโปรไฟล์</title>
    <style>
        body { font-family: sans-serif; background: #f0f2f5; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
        .card { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; max-width: 400px; width: 100%; }
        input[type="file"] { margin: 20px 0; display: block; width: 100%; }
        button { background: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-size: 16px; }
        button:hover { background: #0056b3; }
        a { display: inline-block; margin-top: 15px; color: #007bff; text-decoration: none; }
    </style>
</head>
<body>
    <div class="card">
        <h2>อัปโหลดรูปภาพโปรไฟล์</h2>
        <p>เลือกรูปภาพ <b>Gemini_Generated_Image_jcybz9jcybz9jcyb.png</b> จากเครื่องของคุณเพื่ออัปโหลดเข้าโครงการ</p>
        
        <?php if (isset($msg)) echo $msg; ?>
        
        <form action="" method="POST" enctype="multipart/form-data">
            <input type="file" name="image" accept="image/*" required>
            <button type="submit">อัปโหลดรูปภาพ</button>
        </form>
        <br>
        <a href="index.html">กลับหน้าหลัก</a>
    </div>
</body>
</html>
