-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtem.html
More file actions
62 lines (60 loc) · 1.85 KB
/
Copy pathtem.html
File metadata and controls
62 lines (60 loc) · 1.85 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<title>
Sample script for uploading file to Google Drive without authorization
</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.js"></script>
</head>
<body>
<form
action="https://script.google.com/macros/s/AKfycbxW4WyvxcE_XtRbWwf-fH5GBpwZ3n_To0I5ya-ttTeZClxx2q5ZzYUncCmR7InsJmyB/exec"
id="form"
method="post"
>
Upload a file
<div id="data"></div>
<input name="file" id="uploadfile" type="file" />
<input id="submit" type="submit" />
</form>
<script>
$("#uploadfile").on("change", function () {
var file = this.files[0];
var fr = new FileReader();
fr.fileName = file.name;
fr.onload = function (e) {
e.target.result;
html =
'<input type="hidden" name="data" value="' +
e.target.result.replace(/^.*,/, "") +
'" >';
html +=
'<input type="hidden" name="mimetype" value="' +
e.target.result.match(/^.*(?=;)/)[0] +
'" >';
html +=
'<input type="hidden" name="filename" value="' +
e.target.fileName +
'" >';
$("#data").empty().append(html);
};
fr.readAsDataURL(file);
});
$(document).ready(function () {
$("#form").on("submit", function (e) {
e.preventDefault(); // 阻止表单的默认提交行为
var form = $(this);
$.ajax({
type: form.attr("method"),
url: form.attr("action"),
data: form.serialize(),
success: function (data) {
// 处理响应数据
// $("#response").html(data); // 在页面上的指定元素中显示响应数据
},
});
});
});
</script>
</body>
</html>