You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
teamwk/www2/static/Untitled-1.html

33 lines
806 B

<!DOCTYPE html>
<html>
<head>
<title>文件上传示例</title>
</head>
<body>
<form id="uploadForm" enctype="multipart/form-data">
<input type="file" id="fileInput" name="file">
<button type="button" onclick="uploadImage()">上传图片</button>
</form>
<div id="result"></div>
<script>
function uploadImage() {
var formData = new FormData();
formData.append("file", document.getElementById("fileInput").files[0]);
fetch('/api/upload', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
document.getElementById("result").innerHTML = "识别结果: " + data.result;
})
.catch(error => console.error('Error:', error));
}
</script>
</body>
</html>