Allow any file to be uploaded (#84)
## Summary - Allow any file to be uploaded - Removes .epub restriction ## Additional Context - Fixes #74
This commit is contained in:
@@ -513,13 +513,6 @@ void CrossPointWebServer::handleUpload() {
|
|||||||
Serial.printf("[%lu] [WEB] [UPLOAD] START: %s to path: %s\n", millis(), uploadFileName.c_str(), uploadPath.c_str());
|
Serial.printf("[%lu] [WEB] [UPLOAD] START: %s to path: %s\n", millis(), uploadFileName.c_str(), uploadPath.c_str());
|
||||||
Serial.printf("[%lu] [WEB] [UPLOAD] Free heap: %d bytes\n", millis(), ESP.getFreeHeap());
|
Serial.printf("[%lu] [WEB] [UPLOAD] Free heap: %d bytes\n", millis(), ESP.getFreeHeap());
|
||||||
|
|
||||||
// Validate file extension
|
|
||||||
if (!isEpubFile(uploadFileName)) {
|
|
||||||
uploadError = "Only .epub files are allowed";
|
|
||||||
Serial.printf("[%lu] [WEB] [UPLOAD] REJECTED - not an epub file\n", millis());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create file path
|
// Create file path
|
||||||
String filePath = uploadPath;
|
String filePath = uploadPath;
|
||||||
if (!filePath.endsWith("/")) filePath += "/";
|
if (!filePath.endsWith("/")) filePath += "/";
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
<div class="modal-overlay" id="uploadModal">
|
<div class="modal-overlay" id="uploadModal">
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<button class="modal-close" onclick="closeUploadModal()">×</button>
|
<button class="modal-close" onclick="closeUploadModal()">×</button>
|
||||||
<h3>📤 Upload eBook</h3>
|
<h3>📤 Upload file</h3>
|
||||||
<div class="upload-form">
|
<div class="upload-form">
|
||||||
<p class="file-info">Select an .epub file to upload to <strong id="uploadPathDisplay"></strong></p>
|
<p class="file-info">Select a file to upload to <strong id="uploadPathDisplay"></strong></p>
|
||||||
<input type="file" id="fileInput" accept=".epub" onchange="validateFile()">
|
<input type="file" id="fileInput" onchange="validateFile()">
|
||||||
<button id="uploadBtn" class="upload-btn" onclick="uploadFile()" disabled>Upload</button>
|
<button id="uploadBtn" class="upload-btn" onclick="uploadFile()" disabled>Upload</button>
|
||||||
<div id="progress-container">
|
<div id="progress-container">
|
||||||
<div id="progress-bar"><div id="progress-fill"></div></div>
|
<div id="progress-bar"><div id="progress-fill"></div></div>
|
||||||
@@ -92,19 +92,7 @@
|
|||||||
const fileInput = document.getElementById('fileInput');
|
const fileInput = document.getElementById('fileInput');
|
||||||
const uploadBtn = document.getElementById('uploadBtn');
|
const uploadBtn = document.getElementById('uploadBtn');
|
||||||
const file = fileInput.files[0];
|
const file = fileInput.files[0];
|
||||||
|
uploadBtn.disabled = !file;
|
||||||
if (file) {
|
|
||||||
const fileName = file.name.toLowerCase();
|
|
||||||
if (!fileName.endsWith('.epub')) {
|
|
||||||
alert('Only .epub files are allowed!');
|
|
||||||
fileInput.value = '';
|
|
||||||
uploadBtn.disabled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uploadBtn.disabled = false;
|
|
||||||
} else {
|
|
||||||
uploadBtn.disabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function uploadFile() {
|
function uploadFile() {
|
||||||
@@ -117,12 +105,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileName = file.name.toLowerCase();
|
|
||||||
if (!fileName.endsWith('.epub')) {
|
|
||||||
alert('Only .epub files are allowed!');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user