-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
137 lines (125 loc) · 4.56 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<html>
<head>
<title>S3 POST Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<h4>Please upload the here.</h4>
<form action="https://bucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data" id="form1" >
<input type="hidden" name="key" value="uploads/${filename}">
<input type="hidden" name="AWSAccessKeyId" value="ADD_YOUR_AWS_ACCESS_KEY_HERE">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="policy" value="ADD_YOUR_POLICY_HERE">
<input type="hidden" name="signature" value="ADD_YOUR_SIGNATRE_HERE=">
<input name="file" type="file" id="upload1">
</form>
<br>
<h4>Please upload the file here.</h4>
<form action="https://bucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data" id="form2">
<input type="hidden" name="key" value="uploads/${filename}">
<input type="hidden" name="AWSAccessKeyId" value="ADD_YOUR_AWS_ACCESS_KEY_HERE">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="policy" value="ADD_YOUR_POLICY_HERE">
<input type="hidden" name="signature" value="ADD_YOUR_SIGNATRE_HERE=">
<input name="file" type="file" id="upload2">
</form>
<br>
<h4>Please upload the file here.</h4>
<form action="https://bucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data" id="form3">
<input type="hidden" name="key" value="uploads/${filename}">
<input type="hidden" name="AWSAccessKeyId" value="ADD_YOUR_AWS_ACCESS_KEY_HERE">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="policy" value="ADD_YOUR_POLICY_HERE">
<input type="hidden" name="signature" value="ADD_YOUR_SIGNATRE_HERE=">
<input name="file" type="file" id="upload3">
</form>
<script type="text/javascript">
// override standard upload functionality with ajax upload for the first form
$("#form1").submit(function(e) {
var formobj = $(this);
var formurl = formobj.attr("action");
var formdata = new FormData(this);
$.ajax({
url: formurl,
type: "POST",
data: formdata,
mimeType: "multipart/form-data",
contentType: false,
cache: false,
processData: false,
success: function (data, textStatus, jqXHR) {
console.log("success");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log("error");
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
e.preventDefault();
});
// override standard upload functionality with ajax upload for the second form
$("#form2").submit(function(e) {
var formobj = $(this);
var formurl = formobj.attr("action");
var formdata = new FormData(this);
$.ajax({
url: formurl,
type: "POST",
data: formdata,
mimeType: "multipart/form-data",
contentType: false,
cache: false,
processData: false,
success: function (data, textStatus, jqXHR) {
console.log("success");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log("error");
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
e.preventDefault();
});
// override standard upload functionality with ajax upload for the second form
$("#form3").submit(function(e) {
var formobj = $(this);
var formurl = formobj.attr("action");
var formdata = new FormData(this);
$.ajax({
url: formurl,
type: "POST",
data: formdata,
mimeType: "multipart/form-data",
contentType: false,
cache: false,
processData: false,
success: function (data, textStatus, jqXHR) {
console.log("success");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log("error");
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
e.preventDefault();
});
// Automatically upload the files to s3 when a file is choosen
$('#upload1').on('change', function(){
$(this).submit();
});
$('#upload2').on('change', function(){
$(this).submit();
});
$('#upload3').on('change', function(){
$(this).submit();
});
</script>
</body>
</html>