Send a picture on a Website

ShapeShifter:
::::SNIP::::
If not curl(), surely JavaScript has something similar that does the same thing?

@ShapeShifter,

‘curl’ is a great tool because you must declare your all your parameters upfront and you get the answer back as a stream. In addition, it’s all on one long page of instructions.

The alternatives in Javascript are Jquery, Zepto, jQMobi, many others, and I’m working on one called Ajaxlite. Basically they are all wrappers for the HTTP protocol. I’m going to separate the AJAX from the DOM selector part, versus what the former don’t do - they combine AJAX and the DOM selector.

Jesse

I wasn’t exactly understood this…
Suppose that my picture (image.jpg) was taken and put on the sd card in the folder /arduino/www/

What do I have to do to put my picture on a website with the “curl” command ?

If I will made something like that :

#include <Process.h>

void setup() {
  Bridge.begin();
 
  Process p;        
  p.runShellCommand("curl http://arduino.local/sd/image.jpg");

}

void loop() {
  delay(1000);
}

Where is the picture ?

Please be more specific about what you are trying to do.

I can’t tell if you want to send the picture to a server so that it can be put on a web page (what the title seems to say.) Or perhaps you want a web page that shows the picture that is on the Yun (what most people want to do.) Or do you want to fetch a picture that is on one Yun onto the Yun that is running the script (what the code you posted is trying to do.)

The picture is currently on the SD card of the Yun. Do you want to move the picture somewhere else? If so where? Or do you just want to show the image on a web page?

If the latter, if you use a browser on a computer that is on the local network, and you use the URL http://arduino.local/sd/image.jpg, the picture will be shown in the browser with no other work.

If you want the picture to show up on a web page, then write an HTML file that includes tags with that same URL, and it will show up on that web page.

If you want to picture or web page to be visible to a browser on the Internet and not just on your local network, then things get more complicated.

What exactly are you trying to do? Don’t ask HOW to do it until we are clear WHAT you want to do. If what you want to do is what I think it is, you don’t need curl to do it.

Save jpeg file at SD card:

/etc/init.d/mjpg-streamer  stop
/etc/init.d/mjpg-streamer  disable
mkdir /mnt/sda1/pic
/usr/bin/mjpg_streamer -i "input_uvc.so -y --device /dev/video0"  -o  "output_file.so  -f /mnt/sda1/pic -d 1500"

above will keep save image into folder of /mnt/sda1/pic, in 1500 ms (1.5 s) Interval, file name like "2015_04_07_22_53_56_picture_000000273.jpg","2015_04_07_22_53_58_picture_000000274.jpg".

stop app by

ps
kill PID of "/usr/bin/mjpg_streamer"
nano /mnt/sda1/savepic.sh
#!/bin/ash
/usr/bin/mjpg_streamer -i "input_uvc.so -y --device /dev/video0"  -o  "output_file.so  -f /mnt/sda1/pic -d 1500" 2&>1 >/dev/null
chmod 755 /mnt/sda1/savepic.sh
/mnt/sda1/savepic.sh &
opkg update
opkg install psmisc
killall savepic.sh

UserYun7856:
I wasn’t exactly understood this…
Suppose that my picture (image.jpg) was taken and put on the sd card in the folder /arduino/www/

What do I have to do to put my picture on a website with the “curl” command ?
::::SNIP::::
Where is the picture ?

@UserYun7856,

#include <Process.h>

void setup() {
  Bridge.begin();
 
  Process p;        
  p.runShellCommand("cd /arduino/www/ && curl http://arduino.local/sd/image.jpg");

}

void loop() {
  delay(1000);
}

In the above code example, your image.jpg is already in /arduino/www/, and the ‘curl’ command overwrites the file (image.jpg) with a new image.jpg.

If you want to put (or post) that file to a remote webserver, then you must encode your file for transport (with something like a base64encode), then you must use -X POST it to a remote server. Like this:

 curl -X POST -d {base64data} http://remoteserver.local/fileuploadarea/image.jpg

FYI: there are other methods with “curl” to upload files with.

Otherwise, your webpage should look like this:

<html>
<body>
<img src=image.jpg>
</body>
</html>

Does this help?

Jesse

So I have a little camera who takes pictures (it need 40s for take and save the picture). I want take pictures in loop and after each picture, actualise the website to show the picture taken.

The loop "takePicture()" (look my first post) takes a picture and save it in the sd card into the folder "www/test_liaison_wifi_2"

-o  "output_file.so  -f /mnt/sda1/pic -d 1500"

Use output_file.so instead of output_http.so, by pass mini web server(output_http.so), directly save image into SD.

Use /www/pic will save image into web server (uhttpd).

Use "-d 40000" will save image every 40 sec.

UserYun7856: So I have a little camera who takes pictures (it need 40s for take and save the picture). I want take pictures in loop and after each picture, actualise the website to show the picture taken.

The loop "takePicture()" (look my first post) takes a picture and save it in the sd card into the folder "www/test_liaison_wifi_2"

@UserYun7856,

Sorry. I misunderstood. Use curl from your computer/laptop to test the picture WITHOUT the webpage. Make sure the image is in the directory. Then fix the webpage/Javascript, if you have problems.

Jesse