vendredi 18 avril 2014

jQuery - CakePHP : comment capturer et de télécharger une photo sans déclenchement d'un trou noir de la composante de sécurité ? -Débordement de pile


My intent is to create a "take a picture of yourself" feature on a website I'm creating. The hope is to capture a photo via the webcam and assign it to the user.


I assume (perhaps incorrectly):



  1. I need to use jquery to capture the image.

  2. I should upload the image via the user registration form, and reference it's filename via the db and a known path.


Where I'm stuck:


How do I upload an image once captured by jquery? I'm assume there are some jquery scripts I can grab to take the photo... but how do I get the photo properly uploaded without getting blackholed by the security component?


The answers here might be stupid obvious, but I'm just having trouble wrapping my head around it.




Assuming you're using a normal file field that is populated by jquery, you will need to do something like this:


$this->Form->unlockField('upload_image'); // Set 'upload_image' to the name of your field

(Cookbook reference)


I use this method inside a formHelper that I created to make uploading images easy, it works well.


Edit: incidentally, if using an iPhone or iPad, those devices support taking a picture with the webcam and populating a normal file upload field. I've used an iPhone to upload a webcam picture (taken after the "browse" button is pressed) and it worked fine.



My intent is to create a "take a picture of yourself" feature on a website I'm creating. The hope is to capture a photo via the webcam and assign it to the user.


I assume (perhaps incorrectly):



  1. I need to use jquery to capture the image.

  2. I should upload the image via the user registration form, and reference it's filename via the db and a known path.


Where I'm stuck:


How do I upload an image once captured by jquery? I'm assume there are some jquery scripts I can grab to take the photo... but how do I get the photo properly uploaded without getting blackholed by the security component?


The answers here might be stupid obvious, but I'm just having trouble wrapping my head around it.



Assuming you're using a normal file field that is populated by jquery, you will need to do something like this:


$this->Form->unlockField('upload_image'); // Set 'upload_image' to the name of your field

(Cookbook reference)


I use this method inside a formHelper that I created to make uploading images easy, it works well.


Edit: incidentally, if using an iPhone or iPad, those devices support taking a picture with the webcam and populating a normal file upload field. I've used an iPhone to upload a webcam picture (taken after the "browse" button is pressed) and it worked fine.


0 commentaires:

Enregistrer un commentaire