扫码关注官方订阅号
nodejs怎么得到html中点击<input type="file">选中文件后得到的filelist
闭关修行中......
TALK IS CHECAP, SHOW ME THE CODE
<html> <body> <form> <p> <label>Select file to upload</label> <input type="file"> </p> <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>
一般模拟的问题都可以用phantomjs解决吧,只是效率问题
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
TALK IS CHECAP, SHOW ME THE CODE
一般模拟的问题都可以用phantomjs解决吧,只是效率问题