HTML JS PHP
(a quick example)
<form id="upForm" onsubmit="return up();"> <input type="file" accept="image/*" name="up" required> <input type="submit" value="Upload"> </form>
function up () { GET SELECTED IMAGE var data = new FormData(document. getElementById("upForm"));
AJAX UPLOAD fetch("upload.php", { method:"POST", body:data }) .then(res => res.text()) .then(txt => alert(txt)) .catch(err => console.error(err)); return false; }
SAVE UPLOADED FILE echo move_uploaded_file( $_FILES["up"]["tmp_name"], $_FILES["up"]["name"] ) ? "OK" : "ERROR" ;