Go Down

Topic: upload picture using web server to sd card. (Read 2121 times) previous topic - next topic


hello, i am using a arduino. to created a web server, so far so good. but when i want to create a new function that can upload the picture in my computer to the sd card that located in the arduina, i found out that there is no example and there is no any code that can copy a picture. can anyone help me???

thank u.


Look for tinywebserver, it has an upload fuction.
It's based on the HTML command 'PUT'.
Altough PUT is a normal HTTP command, I found out that most webbrowser convert PUT into GET.
To bypass this, u can use Javasript, something like:

Code: [Select]

<script type="text/javascript">
    // Create the communications object.
    var xmlhttp;
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    else {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    // Set up the request to send data to the server.
    // Make it synchronous, so we know how page rendering should proceed
    async = false;
    resource = "http://192.168.your webaddress";
    data = "your file";
    xmlhttp.open("PUT", resource, async);   

If you find tinywebserver to complicated, you can also use Ladyada's sketch: http://www.ladyada.net/learn/arduino/ethfiles.html, which is also often found on this forum.
In her sketch, you look for the GET command, but you can easily add a routine which looks for PUT.


hallo hong, how about the arduino code?
do you mean that i can use myFile.println("pic in text");
to write my pic to the sd card?


Yes, it's more or less the same as reading from the SDcard and write it to a webbrowser.
In this (opposite) case, you create a loop and write bytes to the SDcard while there are bytes available.
Instead of println you use print, because you write a stream of bytes and you don't want any cr/nl inserted.
When I've time, I'll look for and post an example.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131