<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="file" name="addressBook" id="addressBook">
<input type="button" value="上传" id="gogo"/>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script>
jQuery("#gogo").on('click',function() {
console.log("^^^^^^^^^^^^^^^^^^^^^^^^^");
console.log($("#addressBook"));
console.log($("#addressBook")[0].files);
var formData = new FormData();
formData.append('addressBook', jQuery("#addressBook")[0].files[0]);
jQuery.ajax({
url: "http://127.0.0.1:5000/web/group/upload/",
type: "POST",
data: formData,
dataType: "json",
cache : false,
processData: false,
contentType: false,
success: function (data) {
console.log(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest.status);
}
});
});
</script>
</body>
</html>