Latest Google Chrome Browser stops Flash (AS3) sending POST data to browser

我与影子孤独终老i 提交于 2019-12-11 08:34:22

问题


I have the following code in my AS3 Flash code that takes a screenshot within the swf using JPGEncoder and sends it to the url where i write it to a file in PHP.

This code has worked for a long time but since the very latest Google Chrome Update 33.0.1750.146 the function just stops and the page fails to redirect. Nothing gets sent to save.php

I have tested this in Safari, Firefox, IE and lower versions of Chrome up to 33.0.1750.117 and all work perfectly fine.

So surely it's an issue purely with the latest Chrome? Is there anything i can do to solve this?

My code is:

AS3:

function createJPG(m:MovieClip, q:Number, fileName:String) {
    var jpgSource:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
    jpgSource.draw(stage);
    var jpgScreenshot: BitmapData = new BitmapData(362, 310);
    jpgScreenshot.copyPixels(jpgSource, new Rectangle(288, 89, 362, 310), new Point(0, 0));
    var jpgEncoder:JPGEncoder = new JPGEncoder(q);
    var jpgStream:ByteArray = jpgEncoder.encode(jpgScreenshot);
    var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
    var jpgURLRequest:URLRequest = new URLRequest ("http://www.url.com/save.php");      
    jpgURLRequest.requestHeaders.push(header);              
    jpgURLRequest.method = URLRequestMethod.POST;               
    jpgURLRequest.data = jpgStream;
    var jpgURLLoader:URLLoader = new URLLoader();   
    navigateToURL(jpgURLRequest, "_self");
}

save.php:

$imagefile=''.$imageURL.'';
$fp = fopen($imagefile, 'wb');
fwrite($fp, $GLOBALS['HTTP_RAW_POST_DATA']);
fclose($fp);

header('Location: https://www.url.com/your-image.php');

回答1:


After a lot of searching on the pepperflash issue and trying different methods it seems the following simple change works:

replace:

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

with:

var header:URLRequestHeader = new URLRequestHeader("Content-type","text/plain");

This now works on Chrome and still on all other browsers

Hope this helps anyone else



来源:https://stackoverflow.com/questions/22248217/latest-google-chrome-browser-stops-flash-as3-sending-post-data-to-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!