TALK IS CHECAP, SHOW ME THE CODE <html> <body> <form> <div> <label>Select file to upload</label> <input type="file"> </div> <button id="taozhi" type="submit">Convert</button> </form> <script> var p = document.getElementById("taozhi"); p.onclick = showAlert; function showAlert(event) { // 这就是你需要的吧!!input.files获取选中文件之后的filelist const input = document.querySelector('input[type="file"]') const file = input.files[0] let formData = new FormData(); formData.append('image', file); fetch('http://localhost:8001/upload',{ method:'post', body:formData, }) .then((response) => response.json() ) .then((response)=>{ console.log(response) }) .catch((err)=>console.error(err)); } </script> </body> </html>
TALK IS CHECAP, SHOW ME THE CODE