You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
i am working on a light painting app and i use ajax request to upload bitmap on my ESP8266. If you want to see my complete code, check my repo : imagepainting2 in my working version and imagepainting3 my advance version.
My ajax client request :
void handleFileUpload()
{
//
HTTPUpload& upload = server.upload();
//
FSInfo fs_info;
LittleFS.info(fs_info);
if (upload.contentLength > (fs_info.totalBytes-fs_info.usedBytes))
{
Serial.println("Coucou");
server.send(413, "text/plain", "UPLOAD ERROR : TOO BIG");
return;
}
// Upload start
if (upload.status == UPLOAD_FILE_START)
{
// Retrieve and correct filname
String filename = upload.filename;
if (!filename.startsWith("/")) filename = "/" + filename;
// Open the file for writing in LittleFS (create if it doesn't exist)
UPLOADFILE = LittleFS.open(filename, "w");
}
// Upload in progress
else if (upload.status == UPLOAD_FILE_WRITE)
{
//Write the received bytes to the file
if (UPLOADFILE) UPLOADFILE.write(upload.buf, upload.currentSize);
}
// Upload end
else if (upload.status == UPLOAD_FILE_END)
{
//Close the file
if (UPLOADFILE) UPLOADFILE.close();
}
}
You can see that in my code, i try to reject files that are too big. It work but the client still send the file, it's just the server that doesn't "record" it.
So my question is : how to reject nicely the upload if the file is to big (or other condition) ?
Thanks for you time !!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
i am working on a light painting app and i use ajax request to upload bitmap on my ESP8266. If you want to see my complete code, check my repo : imagepainting2 in my working version and imagepainting3 my advance version.
My ajax client request :
My ESP8266 server part :
You can see that in my code, i try to reject files that are too big. It work but the client still send the file, it's just the server that doesn't "record" it.
So my question is : how to reject nicely the upload if the file is to big (or other condition) ?
Thanks for you time !!
Beta Was this translation helpful? Give feedback.
All reactions