-->
Page 1 of 1

put image on webpage/WiFiManager/ESP8266WebServer/DNSServer

PostPosted: Thu May 12, 2016 4:14 pm
by JoeS
how could I post an image on a page through the ESP8266, i wont have an sd card but some eeprom will be available, or could it be saved in the sketch somewhere?

``String page = FPSTR(HTTP_HEAD);
page.replace("{v}", "MoCa WiFi Setup");
page += FPSTR(HTTP_SCRIPT);
page += FPSTR(HTTP_STYLE);
page += _customHeadElement;
page += FPSTR(HTTP_HEAD_END);
page += "<h1>";
page += _apName;
page += "</h1>";
page += <img src="Pictures/logo.jpg"/>;
//page += F("<h3>WiFiManager</h3>");
page += FPSTR(HTTP_PORTAL_OPTIONS);
page += FPSTR(HTTP_END);

// server->send(200, "image/jpeg", logo);
server->send(200, "text/html", page);
``
im really just editing the WiFiManager.CPP code trying to attach the project logo to the page, stuff was only editte

Re: put image on webpage/WiFiManager/ESP8266WebServer/DNSSer

PostPosted: Thu May 12, 2016 7:34 pm
by martinayotte
First, why are your posting your question twice ?

Second, you need to add an handler for the image/icon such as :

Code: Select allconst char logo_jpg[] PROGMEM = {
  0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
  [... more jpeg data ...]
};

void handleLogo() {
  webserver.send_P(200, PSTR("image/jpeg"), logo_jpg, sizeof(logo_jpeg));
}

void setup() {
 [... some code here ...]
  webserver.on("Pictures/logo.jpg", handleLogo);
 [... some code here ...]
}