Sending local images to a webserver

Using libcurl (http://curl.haxx.se/) and OF I’ve written a small application to use HTTP post to upload an image to a webserver. This can be useful, for example, to turn a webcam (using the OF video grabber) into a “live” updated image…a cheap (but slow) alternative to video streaming. I knew this could be done but I did get some help from Daniel Shiffman’s page on the topic - http://www.shiffman.net/2006/05/02/upload/
His .php file was especially useful.

You can then for example individually refresh the image on a web page without having to reload the whole page using some nifty javascript.

Put this in the tags:

  
<script type="text/javascript">  
refreshImage = function()  
{  
  
img = document.getElementById("cam");  
img.src="images/frame.jpg?rand=" + Math.random();  
}  
</script>  

In the tag place this:

  
<body onload="window.setInterval(refreshImage, 1*1000);">  

and then make sure the image has the “id=cam” attribute, or whatever else you want to call it.

My example code can be found here:
http://www.digitalstar.net/openframeworks/http-post.zip

In order to use libcurl you need to install it (different depending on your platform) and then link your app with it. In Linux and OSX this can be done with the linker directive “-lcurl”. For Visual Studio I think you just add the library to the “additional libraries” in the Linker section of the project properties…but don’t quote me on this!