Hi.
cadence is right. The way to force any browser to download a file is by using the HTTP header field "Content-Disposition: attachment;". You should take into account that the order of the header fields is extremely important, i.e. your script will work in newer versions of I.E. but not in older ones (such as IE 7).
Before this field, I'd recommend you to send also content-type one to notify the mime type of the file that the client is about to download. As an example, you would use "Content-Type: application/pdf" for a PDF file, or "Content-Type: text/csv" for a CSV one.
If you have a look at
http://www.arduino.cc/en/pmwiki.php?n=Tutorial/WebServer:
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
As you see in this example, the code first sends the HTTP version and status code, then the headers, and then the content. You should use, then, something like this:
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Disposition: attachment; filename=\"myfile.csv\";");
client.println("Content-Type: text/csv");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println();
//Print the contents of the file
You've got an example about reading a csv content from a SD card in this page:
http://forum.arduino.cc/index.php?topic=141418.0.
Anyway, I've never used Arduino as a web server. I always prefer using a Raspberry PI and then coding the project in PHP, or even using a PIC32 with the MLA libraries, rather than coding a complete web application for an Arduino board.