Search code examples
phpwebcam

Accessing webcam with PHP?


Is it technically possible using PHP? For example allow visitors of my website to view their own webcam, taking a shot, and upload the file onto a directory, also onto my MySQL-DB.


Solution

  • No, PHP is a server-side language and thus cannot access client hardware.

    However, modern browsers give JavaScript code access to webcam, microphone, etc. so you could record something and then submit it to the server. Photobooth.js might be worth a look.

    Of course you could use Flash, Silverlight or a Java Applet for it, too. But only the former is available on almost every PC. Besides that, you should avoid Flash when you don't absolutely need it.