-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (70 loc) · 2.53 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Caricamento file XLSX e conversione in GIFT</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 50px;
}
#drop_zone {
border: 2px dashed #ccc;
padding: 20px;
text-align: center;
cursor: pointer;
}
</style>
</head>
<body>
<h2>Carica un file XLSX per convertirlo in formato GIFT</h2>
<div id="drop_zone">
Trascina e rilascia qui il file XLSX<br>
oppure <input type="file" id="file_input" accept=".xlsx">
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var dropZone = document.getElementById('drop_zone');
// Aggiungi gestore per il trascinamento del file
dropZone.addEventListener('dragover', function(e) {
e.preventDefault();
dropZone.style.backgroundColor = '#f0f0f0';
});
dropZone.addEventListener('dragleave', function() {
dropZone.style.backgroundColor = '';
});
dropZone.addEventListener('drop', function(e) {
e.preventDefault();
dropZone.style.backgroundColor = '';
var file = e.dataTransfer.files[0];
handleFile(file);
});
// Aggiungi gestore per il caricamento del file tramite input file
document.getElementById('file_input').addEventListener('change', function(e) {
var file = e.target.files[0];
handleFile(file);
});
function handleFile(file) {
if (file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
var formData = new FormData();
formData.append('file', file);
fetch('guerna.php', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(result => {
alert(result);
})
.catch(error => {
console.error('Errore durante il caricamento:', error);
});
} else {
alert('Carica solo file XLSX.');
}
}
});
</script>
</body>
</html>