So I am trying to upload files to the ESP32 using this server and a browser and I can't figure it out...
I got this handler:
Code: Select all
void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
if(!index){
logOutput((String)"UploadStart: " + filename);
}
for(size_t i=0; i<len; i++){
Serial.write(data[i]);
}
if(final){
logOutput((String)"UploadEnd: " + filename + "," + index+len);
}
}
Code: Select all
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest *request) {
request->send(200);
}, handleUpload);
Code: Select all
<form method = "POST" action = /upload>
<input type="file" name="data" data-multiple-caption="{count} files selected" multiple/>
<input type="submit" name="upload" value="Upload" title = "Upload Files">
</form>
I know I am doing something wrong, but I have no idea what. I couldn't find anything useful in the examples or on Google. Maybe because I don't know what to search for.
Any ideas ? What is missing ?
EDIT:
I have also tried the following handler and this time it returned "not found".
Code: Select all
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest *request) {
if(request->hasParam("data", true, true) && SPIFFS.exists(request->getParam("data", true, true)->value()))
request->send(200, "", "UPLOADED: "+request->getParam("data", true, true)->value());
});