Problems using the Ethernet shield to make a web server and making it public

I'm making a web server.
I the Ethernet shield and uses a SD card because my website have pictures.
The pictures won't come out (I already put it in my SD card and it worked on the computer).
I want to make it public.
I failed.

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,20);
EthernetServer server(80);

File webFile;

void setup()
{
    Serial.begin(9600);
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;
    }
    Serial.println("SUCCESS - SD card initialized.");
    
    Ethernet.begin(mac, ip);
    server.begin();
    Serial.begin(9600); 
    
    
    if (!SD.exists("KD3F3C~1.HTM")) {
        Serial.println("ERROR - Can't find KD.html file!");
        return;
    }
    Serial.println("SUCCESS - Found KD.html file.");
}

void loop()
{
    EthernetClient client = server.available();

    if (client) {
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) { 
                char c = client.read();
                if (c == '\n' && currentLineIsBlank) {
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    webFile = SD.open("KD3F3C~1.HTM");
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read());
                        }
                        webFile.close();
                    }
                    break;
                }
                if (c == '\n') {
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    currentLineIsBlank = false;
                }
            } 
        }
        delay(1);
        client.stop();
    }
}

I used the tag in my HTML file.
Attached is my port forwarding.

Your server doesn't serve images, only the main page. You don't even read what is requested by browser and always return the page

here is my complex WebServer if you can extract what you need, You don't need the REST/JSON/AJAX parts of it, but you need the file serving from SD card.

Juraj:
Your server doesn't serve images, only the main page. You don't even read what is requested by browser and always return the page

here is my complex WebServer if you can extract what you need, You don't need the REST/JSON/AJAX parts of it, but you need the file serving from SD card.

Can you briefly explain how that library works? I can't understand it.
And what is REST/JSON/AJAX.
I also want to know how long the Arduino can remain powered before it get brokened because I'm afraid that when I run the Arduino for to long and it broke.

Arduinos don't easily break. People have them running for years.

What happens when a web browser requests a page from a server?

The server sends the page to the browser. The browser analyses it and sees e.g. an image tag. The browser will then request the image (that is specified in that tag) and the server will send the image to the browser. Same principle for e.g. a CSS file or a javascript file.

So your code must be able to handle the needed browser requests.

I searched up online and they only include one image but I have multiple image.
What should I do?

Post the link that you found. I don't have a Ethernet shield so can test anything.

The idea is simple, you get a request, analyse which file is requested and send that file to the browser.

DolphinPig28:
Can you briefly explain how that library works? I can't understand it.
And what is REST/JSON/AJAX.

It is not a library. It is part of a 'multi tab' sketch. NetServer and NetClient are aliases for EthernetServer and EthernetClient (or WiFiServer/WiFiClient). You would copy is and remove the parts you don't need

To write a HTTP server you must know HTTP protocol. (and how to code)

Juraj:
It is not a library. It is part of a 'multi tab' sketch. NetServer and NetClient are aliases for EthernetServer and EthernetClient (or WiFiServer/WiFiClient). You would copy is and remove the parts you don't need

To write a HTTP server you must know HTTP protocol. (and how to code)

When I verify your code, there's a lot of errors such as
'NetServer' does not name a type
What happened? Or it is because my IDE is not compatible with this?
Can you just tell me which part to delete? There's many part about JSON but nothing about AJAX and REST.

DolphinPig28:
When I verify your code, there's a lot of errors such as
'NetServer' does not name a type
What happened? Or it is because my IDE is not compatible with this?
Can you just tell me which part to delete? There's many part about JSON but nothing about AJAX and REST.

Tho project can run on WiFi or Ethernet so the "Net" is defined as Ethernet or WiFi.
Change it for you to EthernetServer/Client.

remove: "enum struct RestRequest", "webServerRestRequest" function, printValuesJson function, printAlarmJson function,

Juraj:
Tho project can run on WiFi or Ethernet so the "Net" is defined as Ethernet or WiFi.
Change it for you to EthernetServer/Client.

remove: "enum struct RestRequest", "webServerRestRequest" function, printValuesJson function, printAlarmJson function,

More error:
'EthernetServer' does not name a type

I included Ethernet library and I solved the declare error.
But there's a new error:
expected unqualified-id before '/' token
It's the "/"in EthernetServer/Client.

DolphinPig28:
I included Ethernet library and I solved the declare error.
But there's a new error:
expected unqualified-id before '/' token
It's the "/"in EthernetServer/Client.

take a coding course or read a book about C++

I have this in my project

#ifdef ethernet_h_
#define NetServer EthernetServer
#define NetClient EthernetClient
#else
#define NetServer WiFiServer
#define NetClient WiFiClient
#endif