-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (76 loc) · 2.54 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
79
80
81
82
83
<!DOCTYPE html>
<html>
<head>
<title>File Uploader</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 30px;
}
.file-upload {
display: flex;
flex-direction: column;
align-items: center;
}
.file-upload input[type="file"] {
display: none;
}
.file-upload label {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
cursor: pointer;
}
.file-upload .file-name {
margin-top: 10px;
font-size: 14px;
}
.file-upload .upload-btn {
margin-top: 20px;
padding: 10px 20px;
background-color: #28a745;
color: #fff;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="file-upload">
<input type="file" id="fileInput" multiple>
<label for="fileInput">Choose Files</label>
<div class="file-name" id="fileNames"></div>
<button class="upload-btn" onclick="uploadFiles()">Upload</button>
</div>
<script>
document.getElementById("fileInput").addEventListener("change", displayFileNames);
function displayFileNames() {
const fileInput = document.getElementById("fileInput");
const fileNamesDiv = document.getElementById("fileNames");
const files = fileInput.files;
if (files.length > 0) {
fileNamesDiv.innerHTML = "Selected Files: <br />";
for (let i = 0; i < files.length; i++) {
const fileName = files[i].name;
fileNamesDiv.innerHTML += fileName + "<br />";
}
} else {
fileNamesDiv.innerHTML = "";
}
}
function uploadFiles() {
const fileInput = document.getElementById("fileInput");
const files = fileInput.files;
if (files.length === 0) {
alert("Please select at least one file to upload.");
return;
}
// Implement your server-side file upload logic here.
// You need to use technologies like PHP, Node.js, etc.,
// to handle the file upload and storage on the server.
// The code below is just a placeholder to show a message.
alert("File upload functionality is not implemented yet. Please handle it on the server-side.");
}
</script>
</body>
</html>