function uploadImage(listingId){var input=document.createElement("input");input.type="file";input.accept="image/jpeg,image/png,image/webp";input.onchange=function(){var fd=new FormData();fd.append("image",input.files[0]);fd.append("listing_id",listingId);fd.append("_csrf",document.querySelector("meta[name=csrf-token]").content);fetch("modules/listings/image-studio/upload.php",{method:"POST",body:fd}).then(r=>r.json()).then(d=>{if(d.success){alert("Image uploaded: "+d.filename);location.reload();}else alert(d.error);});};input.click();}
