Uploading file to SD card from web page.

Hi,

I have and Arduino Mega 2560 and an Arduino Ethernet Shield with a 4GB SDHC card installed. To experiment with this I have been playing with the ethernet library to produce both a web client and server and I thought it would be an interesting challenge to try to pass a file from a browser to the SDHC card on the ethernet shield.

So far I have the server working fine, the html form to produce a browse dialog box and upload button but I have been unable to find a way to pass the file or it's address from this to my firmware. My current objective is to somehow get this information to the firmware so that t can be processed and written to the card.

Does anyone have any suggestions, ideas or pointers on how to do this?

Cheers,

Steve

So far I have the server working fine, the html form to produce a browse dialog box and upload button

What does the upload button do? Show the html file that the server sends to the browser.

but I have been unable to find a way to pass the file or it's address from this to my firmware.

Are you getting the file contents streamed back to the server when the upload button is pressed?

What address are you referring to?

It's just a basic HTML form:

client.println("<form method=\"PUT\" action=""upload"">");
  client.println("File to upload: <input type=""file"" />");
  client.println("<input type=""submit"" value=""Upload"" />");
  client.println("</form>");

What I am stuck with is how to pass the selected file to the arduino. All this does is open a file select window, it's the next bit I can't seem to work out.

The action="upload" is just a place holder. This is where I need to put in the code to stream the file to the arduino.

Thanks,

Steve

You know this really isn't an Arduino issue, right? It's a basic form processing issue.

When the Upload button is pushed, the upload function is called. Typically, that is a cgi script, but it could be an application, a php script, a python script, etc.

That script needs to open the file, and stream the contents back to the server.

Some details:
http://www.cs.tut.fi/~jkorpela/forms/file.html

Yeah I know it's not an Arduino issue, I just thought that someone else here might have tried the same thing and have some pointers.

I just thought that someone else here might have tried the same thing and have some pointers.

Not an unreasonable assumption, if we knew anything about the tools available to you on the client machine to actually do the file send.

Do you have PHP on that machine? Do you know how to use it?

Python? Perl? cgi?