![](/img/trans.png)
[英]How do i save a text with some linked words, with Flex/PHP in mysql?
[英]How do I save a flex application snapshot to a file with PHP and then display it in the browser?
我正在嘗試在我的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);
生成以下輸出(其中{圖像的路徑}是保存圖像的URL):
無法顯示圖像“ {圖像的路徑}”,因為其中包含錯誤。
它確實將.png文件保存到該目錄,但是為空白,沒有任何內容,但是尺寸正確。 我已經確認快照可以通過在拍攝快照后立即使用swfLoader組件將其加載到應用程序中來工作,因此我知道圖像在發送到服務器之前是不錯的。
請改用PNGEncoder 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.