fix: filename uploads (#2831)

Co-authored-by: Christian Schwinne <dev.aircoookie@gmail.com>
This commit is contained in:
Ahad 2022-10-20 19:25:39 -04:00 committed by GitHub
parent 7b2836c63c
commit 3c36030977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);