Fat16 library send file to ethernet client

Hi All, Basically I am trying to write a file on an SD card to an ethernet client using an Arduino Ethernet. I am using the Fat 16 librray available here: http://code.google.com/p/fat16lib/ as the SD library pushes the sketch size too high.

The following are the important lines of code:

file.open("index.htm", O_READ);
server.print(file.read());
file.close();

I suspect it is something to do with the middle line above, but looking at the documentation for both libraries I cannot see where I am going wrong. Can anyone suggest anything or another library I could use?

Cheers in advance

Oops, forgot to say what the problem is.
The sketch runs fine, its just that when the html file is sent to the client, all I get displayed in my browser is a “<” (the first byte of the html file)

The following are the important lines of code:

You seem to be under that impression that file.read() returns more than one character. It does not.

Just re-looked at my sketch using the SD library and I have seen where I have gone wrong, I beleive it should be something along these lines:

if (file){
          while (file.available()){
            client.write(file.read());
          }
          file.close();
        }

Ok, that doesn't work either as there isn't a file.available() function ...

You don't have a file.available() method with that library, but you can get the file size and use a FOR loop to read that number of bytes.

Server code that uploads a file to a browser from the SD card.

//zoomkat 12/26/12
//SD server test code
//open serial monitor to see what the arduino receives
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

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

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 
  192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
String readString; 

//////////////////////

void setup(){

  Serial.begin(9600);

  // disable w5100 while setting up SD
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
  Serial.print("Starting SD..");
  if(!SD.begin(4)) Serial.println("failed");
  else Serial.println("ok");

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  //delay(2000);
  server.begin();
  Serial.println("Ready");
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 
        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

            client.println("HTTP/1.1 200 OK"); //send new page
          //client.println("Content-Type: text/html");
          client.println("Content-Type: image/jpeg");
          //client.println("Content-Type: image/gif");
          //client.println("Content-Type: application/x-javascript");
          //client.println("Content-Type: text");

          client.println();

          //File myFile = SD.open("boom.htm");
          File myFile = SD.open("HYPNO.JPG");
          //File myFile = SD.open("BLUEH_SL.GIF");
          //File myFile = SD.open("SERVOSLD.HTM");

          if (myFile) {

            byte clientBuf[64];
            int clientCount = 0;

            while(myFile.available())
            {
              clientBuf[clientCount] = myFile.read();
              clientCount++;

              if(clientCount > 63)
              {
                // Serial.println("Packet");
                client.write(clientBuf,64);
                clientCount = 0;
              }
            }
            //final <64 byte cleanup packet
            if(clientCount > 0) client.write(clientBuf,clientCount);            
            // close the file:
            myFile.close();
          }
          delay(1);
          //stopping client
          client.stop();
          readString="";
        }
      }
    }
  } 
}