diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino
index 518b48ef3..ebd73199c 100644
--- a/tasmota/xdrv_01_webserver.ino
+++ b/tasmota/xdrv_01_webserver.ino
@@ -353,18 +353,22 @@ const char HTTP_FORM_UPG[] PROGMEM =
"
"
"
"
""
"" D_UPLOAD_STARTED "...
";
// upload via factory partition
const char HTTP_FORM_RST_UPG_FCT[] PROGMEM =
- ""
+ "
"
""
""
"" D_UPLOAD_FACTORY "...
"
@@ -436,6 +440,7 @@ ESP8266WebServer *Webserver;
struct WEB {
String chunk_buffer = ""; // Could be max 2 * CHUNKED_BUFFER_SIZE
+ uint32_t upload_size = 0;
uint16_t upload_error = 0;
uint8_t state = HTTP_OFF;
uint8_t upload_file_type;
@@ -2775,11 +2780,15 @@ void HandleUploadLoop(void) {
return;
}
if (0xE9 == upload.buf[0]) {
- uint32_t bin_flash_size = ESP.magicFlashChipSize((upload.buf[3] & 0xf0) >> 4);
#ifdef ESP8266
+ uint32_t bin_flash_size = ESP.magicFlashChipSize((upload.buf[3] & 0xf0) >> 4);
if (bin_flash_size > ESP.getFlashChipRealSize()) {
#else
- if (bin_flash_size > ESP.getFlashChipSize()) { // TODO revisit this test
+ char tmp[16];
+ WebGetArg("fsz", tmp, sizeof(tmp)); // filesize
+ uint32_t upload_size = (!strlen(tmp)) ? 0 : atoi(tmp);
+ AddLog(LOG_LEVEL_DEBUG, D_LOG_UPLOAD "freespace=%i filesize=%i", ESP.getFreeSketchSpace(), upload_size);
+ if (upload_size > ESP.getFreeSketchSpace()) { // TODO revisit this test
#endif
Web.upload_error = 4; // Program flash size is larger than real flash size
return;