Reputation: 95
I'm using PNGEncoder to write a file on server, with internet explorer or mozilla the file is writed on server, but when i do it with chrome the file is never writed.
This is the PHP that saves the file to sv:
<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
$png = $GLOBALS["HTTP_RAW_POST_DATA"];
header("Content-type: image/png");
echo $png;
}
else echo 'No hay datos binarios';
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
$fp = fopen($_GET['vFoto'], 'wb');
fwrite($fp, $im);
fclose($fp);
echo $_GET['vFoto']." se ha guardado en el servidor";
}
else echo 'No hay datos binarios';
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
$png = $GLOBALS["HTTP_RAW_POST_DATA"];
$img = $_GET["vFoto"];
}
else echo 'No hay datos binarios';
?>
This is where i do the request on AS3:
var bitmapData:BitmapData = new BitmapData(3750,1300);
bitmapData.draw(contenedor);
var file:FileReference = new FileReference();
var bitmap:Bitmap = new Bitmap(bitmapData)
var pngEncoder:PNGEncoder = new PNGEncoder();
var byteArray:ByteArray = PNGEncoder.encode(bitmapData);
var _ruta:String = "form.php";
var _nombre_foto:String = new Date().getTime() + "_entrada.png";
var cabecera:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var urlFoto:URLRequest = new URLRequest();
urlFoto.requestHeaders.push(cabecera);
urlFoto.method = URLRequestMethod.POST;
urlFoto.data = byteArray;
urlFoto.url = _ruta + "?vFoto=" + _nombre_foto;
sendToURL(urlFoto);
trace("Guardado");
Upvotes: 1
Views: 88
Reputation: 6258
Have you looked into console of chrome? I could suspect that it simply doesn't allow local connections, try to put files on server (could be local server using mongoose web server)
or different header like proposed here
Upvotes: 2