내 AS3 및 PHP/Java 지식이 좋지 않아서이 문제에 봉착했습니다.액션 스크립트 3에서 자바 스크립트로 변수 데이터 전송
일부 이미지를 저장하기 위해 비트 맵 데이터를 PHP 파일로 보내는 AS3 함수가 있으며,이 함수에는 다른 인수가 추가되었으며 새 인수는 필자에게 필요한 문자열 값을 제공해야합니다.
private function saveImageForFacebook(evt:MouseEvent)
// Sends the Bitmap data to php
{
var bitmapData:BitmapData=new BitmapData(wheelCanvas.width, wheelCanvas.height);
bitmapData.draw(wheelCanvas);
var jpgEncoder:JPGEncoder = new JPGEncoder(80);
var byteArray:ByteArray = jpgEncoder.encode(bitmapData);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest ("http://www.someurl.com/flash-test/saveimg.php");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = byteArray;
navigateToURL(jpgURLRequest, "_blank");
// Creates the string value that I need to use in saveimg.php
var suffixUrl:String = "";
for(var i:int=0; i < customizedColorArr.length; i++)
{
if(customizedColorArr[i] != "")
{
suffixUrl += "&" + customizedPartValueArr[i] + "=" + customizedColorArr[i];
}
}
suffixUrl = wheelName + "&variant_name=" + variantName + suffixUrl;
trace(suffixUrl);
}
어떻게 든 내 saveimg.php 파일에서 "suffixUrl"값을 추적해야하지만 어떻게해야할지 모르겠다.
내 PHP 파일의 모양과 suffixUrl이 필요한 곳입니다.
<?php
if (isset ($GLOBALS["HTTP_RAW_POST_DATA"])) {
$uniqueStamp = date(U);
//$filename = "temp_image.jpg";
$filename = $uniqueStamp . ".jpg";
$fp = fopen($filename,"wb");
$result = fwrite($fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ]);
fclose($fp);
}
?>
<meta property="og:image" content="http://www.someurl.com/flash-test/src_server/<?php echo $filename ; ?>" />
<SCRIPT LANGUAGE="JavaScript">
function redirect() {
window.location.href = "http://www.facebook.com/sharer.php?u=http://www.someurl/flash-test/Main3D.html?"+suffixUrl, '_self';
}
</SCRIPT>
<BODY onload="redirect()">
내 자바 스크립트 기능에는 "suffixUrl"이 표시됩니다. 그것이 내가 그 값을 치유하려고하는 곳입니다.
문제는 그 값을 saveimg.php에 전달하려고하는데, 이미 동일한 AS 함수로 이미지를 저장하는 데 사용하고 있습니다. –
http://www.someurl.com/flash-test/saveimg.php –