最新的Google Chrome浏览器停止Flash(AS3)向浏览器发送POST数据 [英] Latest Google Chrome Browser stops Flash (AS3) sending POST data to browser

查看:171
本文介绍了最新的Google Chrome浏览器停止Flash(AS3)向浏览器发送POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的AS3 Flash代码中有以下代码,它使用JPGEncoder在swf中截取屏幕截图,并将其发送到我将它写入PHP中的文件的url。



这段代码已经工作了很长时间,但自从最新的Google Chrome Update 33.0.1750.146以来,该功能就停止了,页面无法重定向。没有得到发送到save.php



我已经在Safari,Firefox,IE和更低的版本的Chrome中测试了这个33.0.1750.117和所有工作完全正常。 p>

所以肯定这是纯粹的最新的Chrome的问题?有什么我可以做,以解决这个问题吗?



我的代码是:

AS3:


$ b $ pre $ 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:

  $镜像文件= ''。$ IMAGEURL。 ''; 
$ fp = fopen($ imagefile,'wb');
fwrite($ fp,$ GLOBALS ['HTTP_RAW_POST_DATA']);
fclose($ fp);

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


解决方案

不同的方法看起来如下简单的改变工程:

替换:

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



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

现在可以在Chrome浏览器上运行,并且仍然可以在所有其他浏览器上使用。

希望这有助于其他人


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');

解决方案

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

这篇关于最新的Google Chrome浏览器停止Flash(AS3)向浏览器发送POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆