-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f22f4c2
commit 7ceab1b
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>File Upload</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f7f7f7; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.upload-container { | ||
background-color: white; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
text-align: center; | ||
} | ||
|
||
input[type="file"] { | ||
padding: 10px; | ||
margin: 20px 0; | ||
} | ||
|
||
.upload-container h2 { | ||
margin-bottom: 20px; | ||
} | ||
|
||
button { | ||
background-color: #4CAF50; | ||
color: white; | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="upload-container"> | ||
<h2>Upload Your File</h2> | ||
<input type="file" id="fileInput" /> | ||
<br /> | ||
<button onclick="uploadFile()">Upload</button> | ||
<p id="status"></p> | ||
</div> | ||
|
||
<script> | ||
async function uploadFile() { | ||
const fileInput = document.getElementById('fileInput'); | ||
const file = fileInput.files[0]; | ||
const status = document.getElementById('status'); | ||
|
||
if (file) { | ||
const formData = new FormData(); | ||
formData.append('file', file); | ||
|
||
try { | ||
const response = await fetch('/upload', { | ||
method: 'POST', | ||
body: formData, | ||
}); | ||
|
||
if (response.ok) { | ||
const result = await response.json(); | ||
status.textContent = 'File uploaded successfully: ' + result.filename; | ||
} else { | ||
status.textContent = 'Upload failed!'; | ||
} | ||
} catch (error) { | ||
console.error('Error:', error); | ||
status.textContent = 'Error during upload!'; | ||
} | ||
} else { | ||
status.textContent = 'No file selected!'; | ||
} | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |