This is a quite funny things that, using webcam with PHP language. I am pretty sure that, many of programmers are interested to integrated webcam with php script but don’t know how to do that. Well, it is not difficult to integrate. Let’s dig into php code that how easily we can do that.

Download from Github Demo

Create Necessary Files

To implement this project, I am going to use index.php, a javascript function that will handle webcam and one flash file that will use your cam and sound system.

index.php

<!DOCTYPE html>
<html>
<head>
	<title>Useing webcam with PHP langauge</title>
    <script type="text/javascript" src="webcam.js"></script>
</head>
<body>
    <h1> Using WebCam with PHP Langauge :.: tisuchi.com </h1>
    
  
</body>
</html>

Here I use one js library on top.  Now, I am going to use integrate webcam in this page. Add few line of code after <h1> tag.

 

<script language="JavaScript">
	document.write( webcam.get_html(320, 240) );
</script>

There is two parameter in webcam.get_html() function. Look into two parameters those represent width and height of your webcam frame. You can change it based on your requirement. Let’s look full code, how its look like?

<!DOCTYPE html>
<html>
<head>
     <title>Useing webcam with PHP langauge</title>
     <script type="text/javascript" src="webcam.js"></script>
</head>
<body>
    <h1> Using WebCam with PHP Langauge :.: tisuchi.com </h1>
    

    <script language="JavaScript">
            document.write( webcam.get_html(320, 240) );
    </script>

</body>
</html>


Our code is already done. Now, once again make sure that, in your directory there are 3 files in total as follows-

[directory_name]
     [index.php]
     [webcam.js]
     [webcam.swf]

well, if everything is ok, lets browse index.php file by browser. Sure, enough that you will get a webcam option. Now, click on allow button and sure enough that you can see your face in browser.

Using WebCam with PHP Langauge :.: tisuchi.com

The further process is going on to capture photo from that and upload in your server. To know more, keep in touch with tisuchi.com. Thanks for reading.

About the author

Thouhedul Islam

I am really an error... huh