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

Update j_upl_json.html

Browse files
Files changed (1) hide show
  1. j_upl_json.html +25 -9
j_upl_json.html CHANGED
@@ -31,27 +31,43 @@
31
  }
32
  </style>
33
  </head>
 
34
  <body>
35
  <h1>Upload JSON Data</h1>
36
  <form id="json-upload-form" enctype="multipart/form-data" method="post" action="/j_upload_json">
37
- <input type="file" name="file" accept=".json" required>
38
- <br>
39
  <label for="verify_phone">Verify Phone Number:</label>
40
  <input type="checkbox" id="verify_phone" name="verify_phone" value="1">
41
  <br>
42
  <label for="add_curator">Add Curator:</label>
43
  <input type="checkbox" id="add_curator" name="add_curator" value="1">
44
- <br>
45
  <input type="submit" value="Upload JSON">
46
  </form>
 
47
  <script>
48
- document.getElementById('json-upload-form').onsubmit = function() {
49
- var fileInput = document.querySelector('input[type="file"]');
50
- if (!fileInput.files.length) {
51
- alert('Please select a JSON file.');
52
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
- };
55
  </script>
56
  </body>
57
  </html>
 
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">
38
+ <input type="file" name="file" accept=".json" id="json-file-input">
39
+ <br><br>
40
  <label for="verify_phone">Verify Phone Number:</label>
41
  <input type="checkbox" id="verify_phone" name="verify_phone" value="1">
42
  <br>
43
  <label for="add_curator">Add Curator:</label>
44
  <input type="checkbox" id="add_curator" name="add_curator" value="1">
45
+ <br><br>
46
  <input type="submit" value="Upload JSON">
47
  </form>
48
+
49
  <script>
50
+ document.getElementById('json-file-input').addEventListener('change', function(event) {
51
+ const file = event.target.files[0];
52
+ if (file) {
53
+ const reader = new FileReader();
54
+ reader.onload = function(e) {
55
+ console.log('JSON File Content:', e.target.result);
56
+ };
57
+ reader.readAsText(file);
58
+ }
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
  }
70
+ });
71
  </script>
72
  </body>
73
  </html>