DmitrMakeev commited on
Commit
aa35094
·
verified ·
1 Parent(s): 8ad5917

Update j_upl_json.html

Browse files
Files changed (1) hide show
  1. j_upl_json.html +14 -28
j_upl_json.html CHANGED
@@ -3,35 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <title>Upload JSON</title>
6
- <style>
7
- body {
8
- font-family: Arial, sans-serif;
9
- margin: 20px;
10
- }
11
- h1 {
12
- color: #333;
13
- }
14
- form {
15
- display: flex;
16
- flex-direction: column;
17
- }
18
- label, input {
19
- margin-bottom: 10px;
20
- }
21
- input[type="submit"] {
22
- width: 150px;
23
- padding: 10px;
24
- background-color: #007BFF;
25
- color: white;
26
- border: none;
27
- cursor: pointer;
28
- }
29
- input[type="submit"]:hover {
30
- background-color: #0056b3;
31
- }
32
- </style>
33
  </head>
34
-
35
  <body>
36
  <h1>Upload JSON Data</h1>
37
  <form id="json-upload-form" enctype="multipart/form-data" method="post" action="/j_upload_json">
@@ -59,11 +31,25 @@
59
  });
60
 
61
  document.getElementById('json-upload-form').addEventListener('submit', function(event) {
 
62
  const file = document.getElementById('json-file-input').files[0];
63
  if (file) {
64
  const reader = new FileReader();
65
  reader.onload = function(e) {
66
  console.log('JSON File Content on Submit:', e.target.result);
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  };
68
  reader.readAsText(file);
69
  }
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <title>Upload JSON</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  </head>
 
7
  <body>
8
  <h1>Upload JSON Data</h1>
9
  <form id="json-upload-form" enctype="multipart/form-data" method="post" action="/j_upload_json">
 
31
  });
32
 
33
  document.getElementById('json-upload-form').addEventListener('submit', function(event) {
34
+ event.preventDefault();
35
  const file = document.getElementById('json-file-input').files[0];
36
  if (file) {
37
  const reader = new FileReader();
38
  reader.onload = function(e) {
39
  console.log('JSON File Content on Submit:', e.target.result);
40
+ // Create a formData object and send the request
41
+ const formData = new FormData();
42
+ formData.append('file', file);
43
+ formData.append('verify_phone', document.getElementById('verify_phone').checked ? '1' : '0');
44
+ formData.append('add_curator', document.getElementById('add_curator').checked ? '1' : '0');
45
+
46
+ fetch('/j_upload_json', {
47
+ method: 'POST',
48
+ body: formData
49
+ })
50
+ .then(response => response.json())
51
+ .then(data => console.log('Server response:', data))
52
+ .catch(error => console.error('Error:', error));
53
  };
54
  reader.readAsText(file);
55
  }