开发者

I want to take a photo using the webcam, then pass that data to a JavaScript function

开发者 https://www.devze.com 2022-12-20 15:11 出处:网络
I think this is fairly straight forward but my skills lie in JavaScript and Ruby rather than flash so I want to run this past a few other minds :)

I think this is fairly straight forward but my skills lie in JavaScript and Ruby rather than flash so I want to run this past a few other minds :)

I have a flash file that will take pictures of the user via their web cam. I want to take that newly created image, base64 encode it then pass it to a JavaScript function. That JavaScript function will essentially take this data then embed it into a hidden form element on the page.

When the form is uploaded, I'll reconstruct the image from the base64 encoding back into a jpg.

Can anyone see any gotchas in this approach? I'm already assuming I'll need to use the correct mime-type encoding on the form e开发者_运维百科lement (multipart).


Here's how I'd do it:

  • generate the image
  • encode it using as3corelib, to either JPG or PNG
  • send the binary data to the server using POST

if you want to show the image in the page after data is sent:

  • let the server respond with the new image location
  • pass that location to JavaScript through ExternalInterface, so JavaScript can insert the image into the DOM

It will be signifficatly faster, requires less space (no base64 overhead) and, most importantly, its dead simple ...

also, if you're relying on flash, you might implement the functionality of the whole form in flash ... I see no point in mixing technologies unless there are actual benefits that outweigh the increased maintenance cost ...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号