🐘
upload_image_ui.php
Back
📝 Php ⚡ Executable Ctrl+S: Save • Ctrl+R: Run • Ctrl+F: Find
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Upload Image</title> <style> body { font-family: Arial; padding:20px; background:#f7f7f7; } .container { max-width:500px; margin:auto; background:white; padding:25px; border-radius:8px; } button { background:#2d6cdf; color:white; padding:10px; width:100%; border:none; margin-top:10px; } #result { margin-top:15px; font-weight:bold; } </style> </head> <body> <div class="container"> <h2>Upload Image</h2> <input type="file" id="imageFile" accept="image/*"> <button onclick="uploadImage()">Upload</button> <div id="result"></div> </div> <script> async function uploadImage() { let f = document.getElementById("imageFile").files[0]; if (!f) return document.getElementById("result").textContent = "No file chosen"; let fd = new FormData(); fd.append("image", f); let r = await fetch("upload_image.php", { method: "POST", body: fd }); let j = await r.json(); document.getElementById("result").textContent = j.success ? "Uploaded: " + j.url : j.error; } </script> </body> </html>