user71318: i've just got the EthernetShield and watched a tutorial on how to host a html page with it but i can't find my html page on the SD card.
#include<SPI.h>
#include<Ethernet.h>
#include<SD.h>

byte mac[] = {0xA8, 0x61,0x0A, 0xAE, 0x3A, 0xC4 };

EthernetServer server(80);

File webPage;

void setup() {
  Ethernet.begin(mac);
  server.begin();
  Serial.begin(9600);

  Serial.println(Ethernet.localIP());

  Serial.println("Initializing SD card...");
  if(!SD.begin(4)){
    Serial.println("ERROR - SD card initialization failed!");
    return;
  }
    Serial.println("SUCCESS - SD card initialized.");
    if(!SD.exists("index.htm")){
      Serial.println("ERROR - Can't find index.htm file!");
    }
      Serial.println("SUCCESS - Found  index.htm 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();

          webPage = SD.open("index.htm");
          if(webPage){
            while(webPage.available()){
              client.write(webPage.read());
            }
            webPage.close();
          }
          break;
        }
        if(c == '\n'){
          currentLineIsBlank = true;
        }
        else if(c != '\r'){
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
   }
}


When i save the HTML file i can't save it with the .htm format


user2881: Windows is hiding the extension from you.
The file you showed is either index.htm or index.html. If it's the latter, you could change the windows setting to "show extensions for know filetypes", or change the sketch so it uses index.html instead of `index.htm. I'd go with the latter, as it's the easiest.
EDIT: the SD library doesn't seem to like file extension that are longer than 3 characters. So changing the code to use "index.html" doesn't work.

71318: <p>i've just got the EthernetShield and watched a tutorial on how to host a html page with it but i can't find my html page on the SD card.</p>
<pre><code>#include&lt;SPI.h&gt;
#include&lt;Ethernet.h&gt;
#include&lt;SD.h&gt;

byte mac[] = {0xA8, 0x61,0x0A, 0xAE, 0x3A, 0xC4 };

EthernetServer server(80);

File webPage;

void setup() {
  Ethernet.begin(mac);
  server.begin();
  Serial.begin(9600);

  Serial.println(Ethernet.localIP());

  Serial.println(&quot;Initializing SD card...&quot;);
  if(!SD.begin(4)){
    Serial.println(&quot;ERROR - SD card initialization failed!&quot;);
    return;
  }
    Serial.println(&quot;SUCCESS - SD card initialized.&quot;);
    if(!SD.exists(&quot;index.htm&quot;)){
      Serial.println(&quot;ERROR - Can't find index.htm file!&quot;);
    }
      Serial.println(&quot;SUCCESS - Found  index.htm file.&quot;);
} 

void loop() {
   EthernetClient client = server.available();
   if(client){
    boolean currentLineIsBlank = true;
    while(client.connected()){
      if(client.available()){
        char c = client.read();
        if(c == '\n' &amp;&amp; currentLineIsBlank){
          client.println(&quot;HTTP/1.1 200 OK&quot;);
          client.println(&quot;Content-Type: text/html&quot;);
          client.println(&quot;Connection: close&quot;);
          client.println();

          webPage = SD.open(&quot;index.htm&quot;);
          if(webPage){
            while(webPage.available()){
              client.write(webPage.read());
            }
            webPage.close();
          }
          break;
        }
        if(c == '\n'){
          currentLineIsBlank = true;
        }
        else if(c != '\r'){
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
   }
}
</code></pre>
<p><a href="https://i.stack.imgur.com/KKpuJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KKpuJ.png" alt="enter image description here" /></a></p>
<p>When i save the HTML file i can't save it with the .htm format</p>
<p><a href="https://i.stack.imgur.com/CaiR4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CaiR4.png" alt="enter image description here" /></a></p>
 2881: <p>Windows is hiding the extension from you.</p>
<p>The file you showed is either <code>index.htm</code> or <code>index.html</code>. If it's the latter, you could change the windows setting to &quot;show extensions for know filetypes&quot;, <strike>or change the sketch so it uses <code>index.html</code> instead of `index.htm. I'd go with the latter, as it's the easiest.</strike></p>
<p>EDIT: the SD library doesn't seem to like file extension that are longer than 3 characters. So changing the code to use &quot;index.html&quot; doesn't work.</p>
