-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.html
38 lines (37 loc) · 1.17 KB
/
upload.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>
<form>
<input type="text" class="filename">
<input type="file" name="file" class="imgPath">
<div class="submitBtn">提交</div>
</form>
</div>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.submitBtn').on('click',() => {
var params = new FormData();
params.append('name',$('.filename').val())
params.append('file',$('.imgPath')[0].files[0])
$.ajax({
data: params,
url: 'http://localhost:3000/upload',
type: 'post',
processData: false,
contentType: "application/json",
success: function(res) {
console.log(res)
}
})
})
})
</script>
</body>
</html>