index.html
1.09 KB
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
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>action is everything</title>
</head>
<body>
<div data-th-fragment="header">
<h1> 图片q </h1>
</div>
<form>
<input type="file" id="file" name="file">
<button type="button" onclick="submitForm()">提交</button>
</form>
</body>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
function submitForm() {
var formData = new FormData(); //将需要提交的参数封装起来
formData.append("file", $("#file")[0].files[0]);
$.ajax({
//url:'upload',
url : 'http://121.40.109.21:8083/file-center/file/fileUpload',
beforeSend: function(xhr) {
xhr.setRequestHeader("ossPath","test");
},
type : 'post',
data : formData,
processData : false,
contentType : false,
success : function(value) {
alert(value);
},
error:function (value) {
alert(value);
}
});
}
</script>
</html>