Hi guys, I am trying to create a function that downloads file by file all the files in the sd card by clicking a button in a web browser. At the moment I've got this:
if(download == 1){ //If we have clicked the button
SD.vwd()->rewind();
while (file.openNext(SD.vwd(), O_WRITE)) {
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: application/octet-stream")); //application/zip
// client.println(F("Content-Disposition: attachment; filename = \"2016.zip\""));
client.println(F("Content-Disposition: attachment; file.name()"));
client.println(F("Connnection: close"));
client.println();
Serial.println(F("downloading..."));
char buffer[ BUFSIZE ];
int i;
while ( file.available() )
{
for (i=0 ; (i < BUFSIZE) && (buffer[ i-1 ] >= 0) ; i++)
{
buffer[i] = file.read();
}
client.write( buffer, (buffer[i-1] >= 0) ? i : i-1 );
}
exit;
}
// reset buffer index and all buffer elements to 0
index = 0;
StrClear(clientline, BUFSIZ);
file.close();
Serial.println(F("All files downloaded!"));
}
}
But it does not work, it shows in the serial monitor as if it was downloading it but nothing happens, so if someone could possibly help me to figure out how to correct this code it would be great.
Thanks .