summaryrefslogtreecommitdiff
path: root/client/upload.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/upload.js')
-rw-r--r--client/upload.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/client/upload.js b/client/upload.js
deleted file mode 100644
index fe25bbf..0000000
--- a/client/upload.js
+++ /dev/null
@@ -1,51 +0,0 @@
-
-document.getElementById('uploadForm').addEventListener('submit', async (event) => {
- event.preventDefault();
-
- const fileInput = document.getElementById('fileInput');
- const file = fileInput.files[0];
-
- if (!file) {
- console.log('No file selected.');
- return;
- }
-
- const formData = new FormData();
- formData.append('file', file);
-
- try {
- const response = await fetch('http://localhost:8080/upload', {
- method: 'POST',
- body: formData
- });
-
- const info1h = document.getElementById('info1h');
- const info2h = document.getElementById('info2h');
-
- if (response.ok) {
- const contentType = response.headers.get('Content-Type');
-
- if (contentType && contentType.includes('application/json')) {
- const result = await response.json();
- info1h.innerText = "id=" + result.id;
- info2h.innerText = "key=" + result.key;
- } else {
- const result = await response.text();
- info1h.innerText = result;
- info2h.innerText = "";
- }
-
- info1h.classList.remove('info1');
- info1h.classList.add('info1v');
-
- info2h.classList.remove('info2');
- info2h.classList.add('info2v');
- } else {
- info1h.innerText = response.statusText;
- info1h.classList.remove('info1');
- info1h.classList.add('info1v');
- }
- } catch (error) {
- console.error('Error:', error);
- }
-});