📜  通过 javascript 将文件上传设置为 html 输入 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:43.435000             🧑  作者: Mango

代码示例1
let photo = document.getElementById("image-file").files[0];  // file from input
let req = new XMLHttpRequest();
let formData = new FormData();

formData.append("photo", photo);                                
req.open("POST", '/upload/image');
req.send(formData);