Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const form = document.querySelector("form"); const data = new FormData(form); // Or manually const fd = new FormData(); fd.append("file", fileInput.files[0]); fd.append("title", "My Upload"); const res = await fetch("/api/upload", { method: "POST", body: fd }); // Do NOT set Content-Type header — fetch adds it automatically
Result
Open