Morning everyone, in this few days I search for a lot references online and tried to make my first photobooth program with actionscript and PHP, finally I had done the actionscript part, but when I tried to upload my photo which took from actionscript to server via php, the problem had come. I follow and modify from the references and tutorials I found online, but the php part never work, so the last choice for me is look for professional help here, and below is my source code, any professional please tell me where's the problem is, thanks!


------------------------------------------------------------------------------------------------
ACTIONSCRIPT 3 SIDE:
------------------------------------------------------------------------------------------------

stop();


//START CAMERA FUNCTION


import com.adobe.images.JPGEncoder;


var cam:Camera = Camera.getCamera();


cam.setMode(1890,940,15);


var video:Video = new Video(1900,940);


video.attachCamera(cam);


video.x = 20;


video.y = 20;


addChild(video);


import flash.display.Bitmap;


import flash.display.BitmapData;




var bitmapData:BitmapData = new BitmapData(video.width,video.height);





var imgBD:BitmapData;
var imgBitmap:Bitmap;





//Frame choosing


import flash.events.Event;
import flash.events.MouseEvent;


var addGreen1:Green1 = new Green1();
var addRed2:Red2 = new Red2();
var addYellow3:Yellow3 = new Yellow3();
var addBlue4:Blue4 = new Blue4();
var addOrange5:Orange5 = new Orange5();


btn_cframe.buttonMode=true;
btn1.buttonMode=true;
btn2.buttonMode=true;
btn3.buttonMode=true;
btn4.buttonMode=true;
btn5.buttonMode=true;


btn1.addEventListener(MouseEvent.CLICK, btnone);


function btnone(event:MouseEvent):void {
addGreen1.x= 0
addGreen1.y= 0
addChild(addGreen1);
addChild(addRed2);
addChild(addYellow3);
addChild(addBlue4);
addChild(addOrange5);
removeChild(addRed2);
removeChild(addYellow3);
removeChild(addBlue4);
removeChild(addOrange5);
}


btn2.addEventListener(MouseEvent.CLICK, btntwo);


function btntwo(event:MouseEvent):void {
addRed2.x= 0
addRed2.y= 0
addChild(addGreen1);
addChild(addRed2);
addChild(addYellow3);
addChild(addBlue4);
addChild(addOrange5);
removeChild(addGreen1);
removeChild(addYellow3);
removeChild(addBlue4);
removeChild(addOrange5);
}


btn3.addEventListener(MouseEvent.CLICK, btnthree);


function btnthree(event:MouseEvent):void {
addYellow3.x= 0
addYellow3.y= 0
addChild(addGreen1);
addChild(addRed2);
addChild(addYellow3);
addChild(addBlue4);
addChild(addOrange5);
removeChild(addGreen1);
removeChild(addRed2);
removeChild(addBlue4);
removeChild(addOrange5);
}


btn4.addEventListener(MouseEvent.CLICK, btnfour);


function btnfour(event:MouseEvent):void {
addBlue4.x= 0
addBlue4.y= 0
addChild(addGreen1);
addChild(addRed2);
addChild(addYellow3);
addChild(addBlue4);
addChild(addOrange5);
removeChild(addGreen1);
removeChild(addRed2);
removeChild(addYellow3);
removeChild(addOrange5);
}


btn5.addEventListener(MouseEvent.CLICK, btnfive);


function btnfive(event:MouseEvent):void {
addOrange5.x= 0
addOrange5.y= 0
addChild(addGreen1);
addChild(addRed2);
addChild(addYellow3);
addChild(addBlue4);
addChild(addOrange5);
removeChild(addGreen1);
removeChild(addRed2);
removeChild(addYellow3);
removeChild(addBlue4);
}


//button for user confirm the frame

btn_cframe.addEventListener(MouseEvent.CLICK, btn_cf)


function btn_cf(event:MouseEvent):void {
btn_cframe.gotoAndStop(2);
btn1.visible = false;
btn2.visible = false;
btn3.visible = false;
btn4.visible = false;
btn5.visible = false;
shotBtn.visible=true;
removeBtn.visible=true;
sendBtn.visible=true;
shotBtn.addEventListener(MouseEvent.CLICK, startCountdown);
}





//shot or remove button


shotBtn.visible=false;
removeBtn.visible=false;
sendBtn.visible=false;


shotBtn.buttonMode=true;
removeBtn.buttonMode=true;
sendBtn.buttonMode=true;


var timer1:Timer = new Timer(6000);


timer1.addEventListener(TimerEvent.TIMER, countdowntimer);




var addcd_number:Cd_number = new Cd_number();




shotBtn.addEventListener(MouseEvent.CLICK, startCountdown);


function startCountdown(event:MouseEvent) {

//trigger countdown graphic
addcd_number.x= 788;
addcd_number.y= 355;
addcd_number.gotoAndPlay(2);
addChild(addcd_number);






shotBtn.removeEventListener(MouseEvent.CLICK, startCountdown);


timer1.start();
}

function countdowntimer(e:Event){

timer1.stop();

removeBtn.addEventListener(MouseEvent.CLICK, removeSnapshot);
sendBtn.addEventListener(MouseEvent.CLICK, uploadImage);
removeChild(addcd_number);

bitmapData.draw(video);
imgBD = new BitmapData(1920,994);
imgBD.draw(stage);

imgBitmap = new Bitmap(imgBD);
addChild(imgBitmap);
}

function removeSnapshot(event:MouseEvent):void {
removeChild(imgBitmap);
shotBtn.addEventListener(MouseEvent.CLICK, startCountdown);
removeBtn.removeEventListener(MouseEvent.CLICK, removeSnapshot);
sendBtn.removeEventListener(MouseEvent.CLICK, uploadImage);
}






// for connect the php side


function uploadImage(e:MouseEvent):void {


var myEncoder:JPGEncoder = new JPGEncoder(100);


var byteArray:ByteArray = myEncoder.encode(bitmapData);





var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");





var saveJPG:URLRequest = new URLRequest("post.php?photosNo=" + input_txt.text);


saveJPG.requestHeaders.push(header);


saveJPG.method = URLRequestMethod.POST;


saveJPG.data = byteArray;





var urlLoader:URLLoader = new URLLoader();


urlLoader.load(saveJPG);

navigateToURL(new URLRequest("http://www.google.com"),"_self");


}







------------------------------------------------------------------------------------------------
PHP SIDE:
------------------------------------------------------------------------------------------------

<?php


if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){


$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];


$photosNo = $_GET["photosNo"];


$filename = "images1/". mktime(). ".jpg";


if ($photosNo != 1 && $photosNo != 2 && $photosNo != 3 && $photosNo != 4 && $photosNo != 5) {


$photosNo = "watermark";


}


$overlaying = "images1/" . $photosNo .".png";


$icon = imagecreatefrompng($overlaying);


file_put_contents($filename, $jpg);


$src_img = imagecreatefromjpeg($filename);


imagecopy ($src_img,$icon,0,0,0,0,30,30);


imagejpeg($src_img, $filename);


imagedestroy($icon);


} else{


echo "Encoded JPEG information not received.";


}


$date = date("Ymd");


$sql = "INSERT INTO webcam_booth (picurl,date) VALUES('$filename','$date')";


if(!mysql_query($sql, $con)) {


die("ERROR!" . mysql_error());


} else {


header("Location:index.php");


}


?>




Thanks for your time !