Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP将flex应用程序快照保存到文件中,然后在浏览器中显示它?_Php_Apache Flex_Flash Builder - Fatal编程技术网

如何使用PHP将flex应用程序快照保存到文件中,然后在浏览器中显示它?

如何使用PHP将flex应用程序快照保存到文件中,然后在浏览器中显示它?,php,apache-flex,flash-builder,Php,Apache Flex,Flash Builder,我试图在我的flex应用程序中保存一个组件的快照,然后将其发送到要保存的php脚本,然后将其吐回浏览器窗口。我好像没法让它工作 以下是我的FlashBuilder代码: private function saveImage():void { var parameters:String = "snapshot=" + takeSnapshot(this); var variables:URLVariables = new URLVariables(parameters);

我试图在我的flex应用程序中保存一个组件的快照,然后将其发送到要保存的php脚本,然后将其吐回浏览器窗口。我好像没法让它工作

以下是我的FlashBuilder代码:

private function saveImage():void { 
    var parameters:String = "snapshot=" + takeSnapshot(this);

    var variables:URLVariables = new URLVariables(parameters);
    var submit:URLRequest = new URLRequest("SaveImage.php");
    submit.data = variables;
    submit.method = URLRequestMethod.POST;
    navigateToURL(submit,"_self");
}

private function takeSnapshot(component:IBitmapDrawable):String {
    return ImageSnapshot.encodeImageAsBase64(ImageSnapshot.captureImage(component));
}
以下是我的实验性PHP代码:

$binaryData = base64_decode($_POST["snapshot"]);

$file = "mydirectory/tmp.png";
file_put_contents($file, $binaryData);
header("Content-type: image/png");
die($binaryData);
生成以下输出,其中{path to image}是保存图像的url:

图像“{path to image}”不能为空 显示,因为它包含错误


它确实将一个.png文件保存到该目录中,但它是空的,那里没有任何内容,但它的维度是正确的。我已经确认,快照可以通过在快照拍摄后立即将其加载到带有swfLoader组件的应用程序中来工作,这样在将其发送到服务器之前,我就知道图像是良好的。

请改用该组件。

看起来不错。另一方面,是不是?开始时需要-?快照=否,不需要。事实上,我的代码中已经没有了。谢谢你指出这一点。但是,如果要将参数设置为这样的字符串,那么必须在每个新参数之间包含一个&即var1=somedata&var2=somedataI刚刚添加了php标记,以防万一这是php问题。。