[Javascript] Forward image via http with ajax

Matt Murphy matt.murphy at thermofisher.com
Fri Feb 2 13:17:09 CST 2007


Here's how I think it could work:

Javascript function called by an onclick for *capturing* the picture -
referencing the cgi script on the camera that outputs the actual image.
I know php, so I'll use php as my example, but I'm sure other languages
could do this.

- click "capture" button
- js function sends an AJAX request to the web server -
ajaxme('capturepic.php')
- php script uses CURL to the pre-set URL (the camera) to grab the image
that comes back
- php dumps image into database, determines the img id
- php replies to the ajax function with code like: 
document.getElementById('imgdiv').innerHTML="<img
src=\"displaypic.php?picid=12345\">";

Wouldn't this work? 

Matt

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of John Warner
Sent: Friday, February 02, 2007 7:58 AM
To: '[JavaScript List]'
Subject: RE: [Javascript] Forward image via http with ajax

You are going to have to manage this on the server. JavaScript on the
client is just not up to the task and as noted earlier, thank goodness
that the powers over JavaScript provided that level of security. Imagine
the fun I could have on your computer if I could get you to visit my
website and I could browse your computer.

John Warner


> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Terry Riegel
> Sent: Friday, February 02, 2007 6:43 AM
> To: [JavaScript List]
> Subject: Re: [Javascript] Forward image via http with ajax
> 
> 
> Billy,
> 
> Thanks for the advise. My goal is to create a system that doesn't 
> require any setup on the client machine, or network router. The 
> application's purpose is to grab a persons mug shot, and place it on 
> the web (not the clients hard drive).
> 
> All of your suggestions seem work against that goal.
> 
> Here is what I have accomplished to that end so far...
> 
> 1. Operator plugs in IP camera to ethernet port. IP camera grabs its 
> IP address via DHCP, sends a dns update to dynamic dns service, this 
> will allow the web browser to find it without any knowledge of its IP 
> address. btw this camera does all of this out of the box.
> 2. Operator opens web browser (on their computer, or a borrowed
> computer) and logs into web site. Enters the persons name, address, 
> etc...
>    a. Thw web page would display a live video feed from the camera so 
> it could be positioned, say cheese etc. This is doable now as the IP 
> camera and the client computer are on the same network. No NAT 
> necessary.
>    b. When the operator clicks take picture I need to get the picture 
> from the camera on the intranet to the internet. Currently I can grab 
> a still and show it in the browser, I would like to forward this to 
> the web server on the internet.
> 
> As I see it there are 2 basic approaches that I do not want to use.
> 
> 1. Do port forwarding. This requires control of the network, something

> I am not always going to have.
> 2. Use the client machine with some sort of save to disk, click this 
> upload button and upload. This is less than ideal as it would involve 
> several steps to accomplish
> 
> The approach I am seeking is to have the web browser (via
> javascript)
> grab the image off of the intranet and copy it to the internet using a

> pull then push approach.
> 
> Does this help clarify?
> 
> My other comments can be found inline.
> 
> Thanks,
> 
> Terry
> 
> 
> 
> On Feb 1, 2007, at 11:23 PM, Billy Reisinger wrote:
> 
> > I know you said you wanted to do this with Javascript, and I don't 
> > have any real input to that end.  So I'll point out the obvious 
> > instead - you could set up a cron job or scheduled task on your 
> > intranet computer to grab the image and upload it to your external 
> > site.
> 
> This would require control of the intranet computer, something I may 
> not have. It would also require setup on that computer beyond a web 
> browser.
> 
> > You can always write a bash script (*nix) or a batch file in windows

> > or something to do command line ftp scripting.
> > Even better, if you are using OSX, you can use Automator to do it 
> > instead.  Come to think, there might be an analogous thing in 
> > WIndows, but I'm not much of a Windows user these days.
> 
> Same problem with this approach. I am looking into having the camera 
> FTP or HTTTP an image to the web server directly, so far it looks like

> my $200 camera doesn't do that, but for $700 the next model up can :)
> 
> 
> > Another option is to use something like Ruby to actually simulate 
> > yourself opening your browser and clicking on a form button to 
> > upload the image.  I think there is a program that people
> use to do
> > website testing that automates user interactions like this.  I can't

> > for the life of me remember what it's called, though.
> 
> Similar problem. All of your suggestions require special setup on the 
> client computer. This needs to be a web application in the truest 
> sense of the term.
> 
> 
> > Just a thought.....
> >
> >
> > On Feb 1, 2007, at 7:22 PM, Terry Riegel wrote:
> >
> >> Hello,
> >>
> >> I am working with a IP camera that is able to display an image on 
> >> my web browser (since my computer and the camera are on the same 
> >> network intranet) I would like to push that image via javascript up

> >> to my web server (internet). This would allow me capture an image 
> >> without configuring a router to port forward.
> >>
> >> Is this possible?
> >>
> >> Terry


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list