We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e6b0fc commit 3c470a5Copy full SHA for 3c470a5
2 files changed
uploadFiles/原生上传/use-jquery/index.html
@@ -0,0 +1,35 @@
1
+<!DOCTYPE html>
2
+<html>
3
+
4
+<head>
5
+ <meta charset="UTF-8">
6
+ <title></title>
7
+</head>
8
9
+<body>
10
+ <p>利用二进制blob,配合node的http和fs模块实现上传文件</p>
11
+ <p>后续还可以使用blob.slice方法实现分块上传</p>
12
+ <input type="file" id="file" name="logo" />
13
+</body>
14
+<script src="jquery.js"></script>
15
+<script>
16
+ var fileNode = document.getElementById("file");
17
+ fileNode.onchange = function () {
18
+ $.ajax({
19
+ url: "http://localhost:8877",
20
+ type: "POST",
21
+ dataType: "binary",
22
+ data: fileNode.files[0],
23
+ headers: {
24
+ 'Content-Type': 'application/octet-stream',
25
+ 'X-Requested-With': 'XMLHttpRequest'
26
+ },
27
+ processData: false,
28
+ }).done(function (data) {
29
+ console.log(data);
30
+ })
31
+ fileNode.value = null;
32
+ }
33
+</script>
34
35
+</html>
0 commit comments