Mi consulta es si alguien me puede dar una mano con este Action para enviar una caputra hecha con webcam me faltaria poder enviar campos de texto dinamico al php pero lo intente y me quedan vasios los datos. ¿Como debería enviar la informacion en AS 3.0 ?? necesito enviar datos como nombre, email, empresa, etc.
Me falta; como se ve en el PHP incorporar todos los datos al Action para que haga el envio.
Action:
Código PHP:
import flash.display.Bitmap;
import flash.display.BitmapData;
import com.adobe.images.JPGEncoder;
var snd:Sound = new camerasound();
var bandwidth:int = 0;
var quality:int = 100;
var cam:Camera = Camera.getCamera();
cam.setMode(640,480,30,false);
cam.setQuality(bandwidth, quality);
var video:Video = new Video();
video.attachCamera(cam);
video.x = 20;
video.y = 20;
addChild(video);
var bitmapData:BitmapData = new BitmapData(video.width,video.height);
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 680;
bitmap.y = 20;
addChild(bitmap);
capture_mc.buttonMode = true;
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");
var saveJPG:URLRequest = new URLRequest("guardar.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;
}
}
function warnDown(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.miweb.com/images/"), "_blank");
warn.visible = false;
}
warn.visible = false;
El PHP:
Código PHP:
<?php
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){
$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
$img = $_GET["img"];
$filename = "images/". mktime(). ".jpg";
file_put_contents($filename, $jpg);
$cuerpo = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Web</title>
</head>
<body>
<table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" valign="top">
<p><strong><u>Datos del Contacto:</strong> </p>
<p><strong>Nombre:</strong> '. $_POST["nombre"] .' <br>
<strong>E-mail:</strong> '. $_POST["email"] .' <br>
<strong>Lugar:</strong> '. $_POST["empresa"] .' <br>
</td>
</tr>
</table>
</body>
</html>
';
mail('[email protected],'Datos,$cuerpo,"FROM:- Web -<" . $_POST["email"] .">\nReply-To: $email\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\nX-Priority: 3\nX-MSMail-Priority: High");
} else{
echo "Encoded JPEG information not received.";
}
?>