From 3c360309772f5d7c9e3540ca47817da2102c33f0 Mon Sep 17 00:00:00 2001 From: Ahad Date: Thu, 20 Oct 2022 19:25:39 -0400 Subject: [PATCH] fix: filename uploads (#2831) Co-authored-by: Christian Schwinne --- wled00/wled_server.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index 626c2708..9775da24 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -37,10 +37,15 @@ void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t return; } if (!index) { - request->_tempFile = WLED_FS.open(filename, "w"); + String finalname = filename; + if (finalname.charAt(0) != '/') { + finalname = "/" + finalname; // prepend slash if missing + } + + request->_tempFile = WLED_FS.open(finalname, "w"); DEBUG_PRINT("Uploading "); - DEBUG_PRINTLN(filename); - if (filename == F("/presets.json")) presetsModifiedTime = toki.second(); + DEBUG_PRINTLN(finalname); + if (finalname == "/presets.json") presetsModifiedTime = toki.second(); } if (len) { request->_tempFile.write(data,len);