-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possible to select a filename on custom page #50
Comments
You can use a #include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <AutoConnect.h>
static const char PAGE_FILENAME[] PROGMEM = R"(
[
{
"title": "File name input",
"uri": "/input",
"menu": true,
"element": [
{
"name": "caption",
"type": "ACText",
"value": "File name input Demo."
},
{
"name": "filename",
"type": "ACElement"
},
{
"name": "send",
"type": "ACSubmit",
"value": "Upload",
"uri": "/echo"
}
]
},
{
"title": "File name",
"uri": "/echo",
"menu": false,
"element": [
{
"name": "caption",
"type": "ACElement",
"value": "File name: "
},
{
"name": "echo",
"type": "ACElement"
}
]
}
]
)";
AutoConnect portal;
String selectFile(AutoConnectAux &aux, PageArgument& args) {
AutoConnectElement* elmFilename = aux.getElement("filename");
elmFilename->value = "Select file: <input type=\"file\" name=\"filename\">";
return String();
}
String echoBack(AutoConnectAux &aux, PageArgument& args) {
AutoConnectAux* auxInput = portal.aux("/input");
AutoConnectElement* elmFilename = auxInput->getElement("filename");
String fileName = elmFilename->value;
Serial.print("File name:");
Serial.println(fileName);
AutoConnectElement* elmEcho = aux.getElement("echo");
elmEcho->value = fileName;
return String();
}
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
portal.load(PAGE_FILENAME);
portal.on("/input", selectFile);
portal.on("/echo", echoBack);
portal.begin();
}
void loop() {
portal.handleClient();
} |
@ageurtse Until you pointed out, I thought that I could handle
You always suggest to me what is missing. Thank you. |
P.S. @ageurtse
For adding the entype, the library shoud be improved. For the upload hander, we can specify the handler with ESP8266WebServer::onFileUpload function. |
I ask this so i can make a custom page for webupdating, yes there is it again. |
For now, combining ESP8266HTTPUpdateServer makes it possible to incorporate OTA into the AutoConnect menu even with v0.9.7. #include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
#include <AutoConnect.h>
const char* host = "esp8266-webupdate";
static const char AUX_AppPage[] PROGMEM = R"(
{
"title": "Hello world",
"uri": "/",
"menu": true,
"element": [
{
"name": "caption",
"type": "ACText",
"value": "<h2>Hello, world</h2>",
"style": "text-align:center;color:#2f4f4f;padding:10px;"
},
{
"name": "content",
"type": "ACText",
"value": "In this page, place the custom web page handled by the sketch application."
}
]
}
)";
ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;
AutoConnect portal(httpServer);
AutoConnectAux hello;
AutoConnectAux update("/update", "Update");
void setup(void) {
delay(1000);
Serial.begin(115200);
Serial.println("\nBooting Sketch...");
httpUpdater.setup(&httpServer);
hello.load(AUX_AppPage);
portal.join({ hello, update });
portal.begin();
MDNS.begin(host);
MDNS.addService("http", "tcp", 80);
Serial.printf("HTTPUpdateServer ready! Open http://%s.local/update in your browser\n", host);
}
void loop(void) {
portal.handleClient();
} However, I'm now designing some functions inspired by your request and please review whether these two features meet your requirements.
|
this is nice, i didn't know of this :) thanks, for helping. |
I supported a new element AutoConnectFile which can select a file and upload it with built-in upload handler. The built-in upload handler receives a file and saves to SPIFFS/SD automatically without the sketch code, and you can store it an external also by your owned sketch code. It has been previewed on the develop branch enhance/v098. |
Merged #57 |
Is it possible to select a filename on a custom webpage, or is there a way to implement this.
I realy would like to have this feather.
The text was updated successfully, but these errors were encountered: