Fix issue with uploading to subfolders

This commit is contained in:
Brendan O'Leary 2025-12-16 21:20:45 -05:00
parent 2aa1584582
commit 9c68d80781
2 changed files with 7 additions and 4 deletions

View File

@ -721,7 +721,6 @@ static const char* FILES_PAGE_FOOTER = R"rawliteral(
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
formData.append('path', currentPath);
const progressContainer = document.getElementById('progress-container'); const progressContainer = document.getElementById('progress-container');
const progressFill = document.getElementById('progress-fill'); const progressFill = document.getElementById('progress-fill');
@ -732,7 +731,9 @@ static const char* FILES_PAGE_FOOTER = R"rawliteral(
uploadBtn.disabled = true; uploadBtn.disabled = true;
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', '/upload', true); // Include path as query parameter since multipart form data doesn't make
// form fields available until after file upload completes
xhr.open('POST', '/upload?path=' + encodeURIComponent(currentPath), true);
xhr.upload.onprogress = function(e) { xhr.upload.onprogress = function(e) {
if (e.lengthComputable) { if (e.lengthComputable) {
@ -1241,7 +1242,9 @@ void CrossPointWebServer::handleUpload() {
uploadSuccess = false; uploadSuccess = false;
uploadError = ""; uploadError = "";
// Get upload path from form data (defaults to root if not specified) // Get upload path from query parameter (defaults to root if not specified)
// Note: We use query parameter instead of form data because multipart form
// fields aren't available until after file upload completes
if (server->hasArg("path")) { if (server->hasArg("path")) {
uploadPath = server->arg("path"); uploadPath = server->arg("path");
// Ensure path starts with / // Ensure path starts with /

View File

@ -581,7 +581,7 @@ void WifiScreen::renderConnected() const {
std::string webInfo = "Web: http://" + connectedIP + "/"; std::string webInfo = "Web: http://" + connectedIP + "/";
renderer.drawCenteredText(UI_FONT_ID, top + 70, webInfo.c_str(), true, REGULAR); renderer.drawCenteredText(UI_FONT_ID, top + 70, webInfo.c_str(), true, REGULAR);
renderer.drawCenteredText(SMALL_FONT_ID, pageHeight - 30, "Press any button to continue", true, REGULAR); renderer.drawCenteredText(SMALL_FONT_ID, pageHeight - 30, "Press any button to exit", true, REGULAR);
} }
void WifiScreen::renderSavePrompt() const { void WifiScreen::renderSavePrompt() const {