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???
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:
<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);
xmlhttp.send(data);
</script>
If you find tinywebserver to complicated, you can also use Ladyada's sketch: Arduino Tutorials - Ethernet+SD, 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.
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.