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
Here is my form post handler code for the server side:
void handle_upload(HTTPRequest * req, HTTPResponse * res)
{
Serial.println("Handle_upload");
HTTPBodyParser *parser;
parser = new HTTPMultipartBodyParser(req);
bool didwrite = false;
Serial.println( "Handle_upload 2" );
while(parser->nextField()) {
Serial.println( "Handle_upload 3" );
std::string name = parser->getFieldName();
std::string filename = parser->getFieldFilename();
std::string mimeType = parser->getFieldMimeType();
Serial.printf("handleFormUpload: field name='%s', filename='%s', mimetype='%s'\n", name.c_str(), filename.c_str(), mimeType.c_str() );
if ( ! (filename.rfind("/", 0) == 0) )
{
filename = "/" + filename;
}
Serial.print("handle_upload Name: ");
Serial.println(filename.c_str() );
fsUploadFile = LITTLEFS.open( filename.c_str(), "w"); // Open the file for writing in SPIFFS (create if it doesn't exist)
size_t fileLength = 0;
didwrite = true;
while (!parser->endOfField()) {
byte buf[512];
size_t readLength = parser->read(buf, 512);
fsUploadFile.write(buf, readLength);
fileLength += readLength;
}
fsUploadFile.close();
res->printf("<p>Saved %d bytes to %s</p>", (int)fileLength, filename.c_str() );
}
if (!didwrite) {
res->println("<p>Did not write any file contents</p>");
}
delete parser;
if(didwrite)
{ // If the file was successfully created
res->setHeader("Location", "/success");
res->setStatusCode(303);
}
else
{
res->setStatusCode(500);
res->setStatusText("Upload failed");
}
}
The upload works, stores the file in the ESP32 SPIFFS file system (using LittleFS)
and here are the file contents (printed out as ASCII character and Hex value):
I tested Picojpeg using a jpeg file I created in Pixelmator for Mac and Picojpeg
works fine. I use the same HTTPS Server code to upload the file contents. I use
this HTML:
Hi - Sorry you're using a bunch of technologies which aren't my strong suite (like web tech). If you're having a problem with the decoder itself, I would be glad to help.
Thank you for Picojpeg. I found it embeded in Bodmer's JPEGDecoder
https://github.com/Bodmer/JPEGDecoder/blob/master/src/picojpeg.h and
used to display images on a 135x240 pixel OLED display.
I created a 10x10 pixel JPEG encoded image from a Javascript context
using this code:
I am using FHessel's HTTPS Server on ESP32 to receive the form post from
a Chrome browser.
https://github.com/fhessel/esp32_https_server
Here is my form post handler code for the server side:
The upload works, stores the file in the ESP32 SPIFFS file system (using LittleFS)
and here are the file contents (printed out as ASCII character and Hex value):
Picojpeg rejects the file and throws error 19.
I tested Picojpeg using a jpeg file I created in Pixelmator for Mac and Picojpeg
works fine. I use the same HTTPS Server code to upload the file contents. I use
this HTML:
This uploads the Jpeg file correctly. And Picojpeg decodes the jpeg image
correctly and with no error.
I'm not sure where to go next? Any help would be appreciated.
-Frank
The text was updated successfully, but these errors were encountered: