So I have a form, and in this form a user can upload a picture. As an alternative, I want them to be able to take a picture and upload that instead.
Now I figure that when a user takes a picture with some sort of flash webcam interface, that picture needs to be stored in some sort of intermediary memory while the user completes his/her form.
Is there a way around this? What’s the best solution?
I figure there are only really two options.
Either (a) I hold the temporary photo and then accept it again once the form is submitted or (b) the user takes a picture, it’s downloaded onto their local machine, and they have to choose it as a file to be submitted again.
Neither of these solutions are really satisfactory to me, so I wanted to know if there’s any better way to do this.
Edit: As an added bonus, although it’s not really relevant, I’m making a Rails app with Paperclip for file attachments. Also, I prefer to work with jQuery…
Also just general opinions from experienced UI web developers would be nice..
I’d used this: http://www.xarg.org/project/jquery-webcam-plugin/ in my rails application for capturing an image from a webcam. You can download this jQuery-webcam here: https://github.com/infusion/jQuery-webcam
Here is a roughly done implementation, sorry for the messy code:
views/layouts/webcam.html.erb:
views/pictures/capture.html.erb:
Just make sure that, “jscam.swf” file referenced in jquery.webcam.js is loaded on page properly.
routes you can define in your routes.rb are:
From here, you can then use this: https://github.com/blueimp/jQuery-File-Upload for uploading it using an Ajax form submission!!
Do let me know if you have any questions.