Pages: [1]   Go Down
Author Topic: Uploading file to SD card from web page.  (Read 7120 times)
0 Members and 1 Guest are viewing this topic.
Westfield or Portsmouth, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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?
Logged

Westfield or Portsmouth, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's just a basic HTML form:

Code:
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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Westfield or Portsmouth, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Pages: [1]   Go Up
Jump to: