views:

230

answers:

1

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 element (multipart).

A: 

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 ...

greetz

back2dos

back2dos
Hmm, when the image upload completes I could store a reference to the uploaded image in a hidden form var. The problem then is I need a further step with a "Save Image" button which will post the data (I wouldn't want to do it each time the user clicks snapshop, they might take 5 or 6 photos before they get the "right" one)
Samuel
@Samuel: why not put the "Save image" in the Flash movie, right next to the "Snapshot button" under the preview? How would embeding the base64 encoded image in a hidden form field circumvent the necessity of this step?
back2dos