bitmapData.encode question
Hey everyone, i recently posted a forum question about how to use the encoding to JPEG the best way, and i got my answer.
but im heaving trouble converting it to ByteArray.
i've tried both ways:
var b:ByteArray = new ByteArray();
b = img.encode(img.rect,new flash.display.JPEGEncoderOptions(80));
and..
var b:ByteArray = new ByteArray();
img.encode(img.rect,new flash.display.JPEGEncoderOptions(80),b);
but non of them worked. cuz i cant send it via php and save it. as this:
var php_vars: URLVariables = new URLVariables();
var php_send: URLRequest = new URLRequest("http://streamsniffer.com/sharf/upload.php");
php_send.method = URLRequestMethod.POST;
var php_loader:URLLoader = new URLLoader;
php_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
php_loader.addEventListener(Event.COMPLETE,returnfunc);
var b:ByteArray = new ByteArray();
b = img.encode(img.rect,new flash.display.JPEGEncoderOptions(80));
//addChild(new img);
php_vars.img = b;
php_send.data = php_vars;
php_loader.load(php_send);
and inside my upload.php code:
<?php
if (!file_exists('uploads')) {
mkdir('uploads', 0777, true);
}
chdir("uploads");
$a = 1;
while (file_exists($a.".jpg"))
{
$a++;
}
$a = $a.".jpg";
if (isset( $_POST["img"]))
{
$jpg = $_POST["img"];
$fp = fopen( $a, 'w+' );
fwrite($fp,$jpg);
fclose($fp);
}
print "fname=".$a;
?>
from this whole code, my new image file is created successfully, but its empty.
any ideas where am i wrong here?
