html – jpg / png Problems with Huzzah ESP2866 + Arduino IDE

I am using a Huzzah ESP2866 with Arduino IDE. I'm trying to upload images with html + spiffy, but the broken image logo still appears. The text works well. Also, the HTML file will open with a working image in a browser, so I'm pretty sure the location of jpeg / png is not the problem.
I also tried different jpegs / pngs, but the same result.

I use code from here:

The text works well. The HTML file is also opened with a working image in a browser. So I'm pretty sure the JPEG position is not the problem. I also tried different jpegs / pngs, but the same result.

I use code from here:
https://circuits4you.com/2018/01/31/upload-image-png-jpeg-to-esp8266-web-page/

index.html





This example shows how to load images from the ESP8266 Web server "Image" and HTML web page files are uploaded to ESP Flash with the SPIFFS tool:

Picture of ESP8266

ESP.ino

* ESP8266 SPIFF HTML web page with JPEG, PNG image
*
* /

#include 
#include 
#include    // Include file system headers

const char * imagefile = "http://stackoverflow.com/image.png";
const char * htmlfile = "index.html";

// Configuration of the ESP-AP mode
const char * ssid = "image-demo-circuits4you.com";
const char * password = "password";


ESP8266 Web server server (80);

void handleRoot () {
server.sendHeader ("Location", "/index.html",true); // Forward to
our HTML website
server.send (302, "text / plane", "");
}

void handleWebRequests () {
if (loadFromSpiffs (server.uri ())) return;
String message = "File not found  n  n";
message + = "URI:";
message + = server.uri ();
message + = " nMethod:";
message + = (server.method () == HTTP_GET)? "GET": "POST";
message + = " nArguments:";
message + = server.args ();
Message + = " n";
for (uint8_t i = 0; i <server.args (); i ++) {
message + = "NAME:" + server.argName (i) + " n VALUE:" + server.arg (i)
+ " n";
}
server.send (404, "text / plain", message);
Serial.println (message);
}

void setup () {
Delay (1000);
Series start (115200);
Serial.println ();

// initialize file system
SPIFFS.begin ();
Serial.println ("file system initialized");

// Initialize AP mode
WiFi.softAP (ssid); // password not used
IP address myIP = WiFi.softAPIP ();
Serial.print ("Web Server IP:");
Serial.println (myIP);

// Initialize web server
server.on ("/", handleRoot);
server.onNotFound (handleWebRequests); // set all paths
not found, so we can handle via URI
server.begin ();
}

Empty loop () {
server.handleClient ();
}

bool loadFromSpiffs (String Path) {
String dataType = "text / plain";
if (path.endsWith ("/")) path + = "index.htm";

if (path.endsWith (".src")) path = path.substring (0,
path.lastIndexOf ("."));
else if (path.endsWith (".html")) dataType = "text / html";
else if (path.endsWith (".htm")) dataType = "text / html";
else if (path.endsWith (".css")) dataType = "text / css";
else if (path.endsWith (".js")) dataType = "application / javascript";
else if (path.endsWith (".png")) dataType = "image / png";
else if (path.endsWith (".gif")) dataType = "image / gif";
else if (path.endsWith (".jpg")) dataType = "image / jpeg";
else if (path.endsWith (".ico")) dataType = "image / x-icon";
else if (path.endsWith (".xml")) dataType = "text / xml";
else if (path.endsWith (".pdf")) dataType = "application / pdf";
else if (path.endsWith (".zip")) dataType = "application / zip";
File dataFile = SPIFFS.open (path.c_str (), "r");
if (server.hasArg ("download")) dataType = "application / octet-
Electricity";
if (server.streamFile (dataFile, dataType)! = dataFile.size ()) {
}

dataFile.close ();
return true;
}