summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-02-13 10:24:46 +0100
committerache <ache@ache.one>2019-02-13 10:24:46 +0100
commit3125d34b61a4989d162f4a9bfaf8d2973bc3489b (patch)
tree42a272586ff3fea57af3a5edb4a02e95503adc35
parentSupport PUT method (diff)
test PUT front-end
-rw-r--r--test2.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/test2.html b/test2.html
new file mode 100644
index 0000000..d68444d
--- /dev/null
+++ b/test2.html
@@ -0,0 +1,36 @@
+<html>
+<head>
+</head>
+<body>
+ <label for="file_input">Select Files:</label>
+ <input id="fileinput" type="file">
+<script language="javascript">
+ // Select your input type file and store it in a variable
+const input = document.getElementById('fileinput');
+
+// This will upload the file after having read it
+const upload = (file) => {
+ fetch('http://localhost:8080/oups', { // Your POST endpoint
+ method: 'PUT',
+// headers: {
+// "Content-Type": ""
+// },
+ body: file // This is your file object
+ }).then(
+ response => response.json() // if the response is a JSON object
+ ).then(
+ success => console.log(success) // Handle the success response object
+ ).catch(
+ error => console.log(error) // Handle the error response object
+ );
+};
+
+// Event handler executed when a file is selected
+const onSelectFile = () => upload(input.files[0]);
+
+// Add a listener on your input
+// It will be triggered when a file will be selected
+input.addEventListener('change', onSelectFile, false);
+</script>
+</body>
+</html>