How to Make Online Photo Capturing Application Using Flash and PHP

In this tutorial am going to explain how to create a webcam photo capturing application using Flash and PHP. This application works on flash platform. Flash will capture the photo and send to PHP to save it in web directory. I will also explain you the action script used to develop this application.
Online photo capturing application using flash and PHP

Photo capturing application using Flash and PHP
Basically it will create a video and get a bitmap image from it. The JPGE encoder will make it as a jpg image and send it to PHP. PHP will get image from flash using $GLOBALS["HTTP_RAW_POST_DATA"] and save it in a directory.

How to Make Online Photo Capturing Application Using Flash and PHP,Make Online Photo Capturing Application,Online Photo Capturing Application,Photo Capturing Application,Flash and PHP




















  • You can view demo and download the example file below:

Demo                 Download

main code
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import com.adobe.images.JPGEncoder;
    //Sound for the "Capture" button click
    var snd:Sound = new camerasound();
    //Set the maximum amount of bandwidth that the current outgoing video feed can use
    //Should be in bytes per second.
    var bandwidth:int = 0;
    // This value is 0-100 with 1 being the lowest quality.
    var quality:int = 100;
    //Run Camera
    var cam:Camera = Camera.getCamera();
    cam.setQuality(bandwidth, quality);
    //Now setMode(videoWidth, videoHeight, video fps, favor area)
    cam.setMode(320,240,30,false);
    var video:Video = new Video();
    video.attachCamera(cam);
    video.x = 20;
    video.y = 20;
    addChild(video);
    //Image Data
    var bitmapData:BitmapData = new BitmapData(video.width,video.height);
    var bitmap:Bitmap = new Bitmap(bitmapData);
    //Set height and width for image
    bitmap.x = 360;
    bitmap.y = 20;
    addChild(bitmap);
    capture_mc.buttonMode = true;
    //OnClick image captur
    capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
    function captureImage(e:MouseEvent):void {
    snd.play();
    bitmapData.draw(video);
    save_mc.buttonMode = true;
    save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
    save_mc.alpha = 1;
    }
    save_mc.alpha = .5;
    function onSaveJPG(e:Event):void{
    var myEncoder:JPGEncoder = new JPGEncoder(100);
    var byteArray:ByteArray = myEncoder.encode(bitmapData);
    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    //PHP fle to save the image
    var saveJPG:URLRequest = new URLRequest("save.php");
    saveJPG.requestHeaders.push(header);
    saveJPG.method = URLRequestMethod.POST;
    saveJPG.data = byteArray;
    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, sendComplete);
    urlLoader.load(saveJPG);
    function sendComplete(event:Event):void{
    warn.visible = true;
    addChild(warn);
    warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
    warn.buttonMode = true;
    }
    } 
Now flash captured image will send to save.php. Below is the php script to save this image in a directory. 

0 Comments
Disqus
Fb Comments
Comments :

0 comments:

Post a Comment