Взято с forum.vingrad.ru/
[cc lang=»actionscript»] import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.utils.ByteArray;
var ByteLoader:URLLoader;
var ByteConverter:Loader;
var ByteConverter2:Loader;
var FileRequest:URLRequest;
var ba:ByteArray = new ByteArray;
function convert(event:Event)
{
//function BytesExample (event:Event) {
ByteLoader = new URLLoader();
ByteLoader.dataFormat = URLLoaderDataFormat.BINARY;
ByteLoader.addEventListener (Event.COMPLETE, onBytesLoaded);
FileRequest = new URLRequest («mov.swf»);
ByteLoader.load (FileRequest);
//}
function onBytesLoaded (evt:Event)
{
ByteConverter = new Loader();
ByteConverter.contentLoaderInfo.addEventListener (Event.COMPLETE, onConvertFinished);
ByteConverter.loadBytes (ByteLoader.data);
ba.writeBytes(ByteLoader.data);
//urla
var url_req:URLRequest = new URLRequest(«http://127.0.0.1/img_create.php»);
url_req.data = ba;
url_req.method = URLRequestMethod.POST;
var header:URLRequestHeader = new URLRequestHeader («Content-type», «application/octet-stream»);
url_req.requestHeaders.push(header);
navigateToURL(url_req, «png»);
}
function onConvertFinished (evt:Event)
{
var mc = ByteConverter.content;
trace (ba);
mc.x = 0;
mc.y = 0;
mc.alpha = .75;
addChild (mc);
}
}
bt.addEventListener(MouseEvent.CLICK, convert);
[/cc] Серверный код:
[cc lang=»php»] header(«Expires: Mon, 26 Jul 1997 05:00:00 GMT»);
header(«Last-Modified: » . gmdate(«D, d M Y H:i:s») . » GMT»);
header(«Cache-Control: no-store, no-cache, must-revalidate»);
header(«Cache-Control: post-check=0, pre-check=0», false);
header(«Pragma: no-cache»);
$image_data = $GLOBALS[«HTTP_RAW_POST_DATA»] ;
$filename_to_save = «avatar.swf»;
if(isset($image_data)){
$png_file = fopen($filename_to_save, «wb») or die(«File not opened!»);
if($png_file){
set_file_buffer($png_file, 20);
fwrite($png_file, $image_data);
fclose($png_file);
}
}
echo(«
«);
?>
[/cc]