Highlighted

bitmapData.encode question

Explorer ,
Apr 08, 2018

Copy link to clipboard

Copied

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?

TOPICS
Development

Views

213

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

bitmapData.encode question

Explorer ,
Apr 08, 2018

Copy link to clipboard

Copied

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?

TOPICS
Development

Views

214

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 08, 2018 0
Adobe Community Professional ,
Apr 08, 2018

Copy link to clipboard

Copied

I don't know PHP, but apparently you can directly use byteArray as the post data. I think that would be:

php_send.data = b;

and:

$fp = fopen( $fname, "wb" );

fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );

fclose( $fp );

See this page for people who know what they're talking about!:

actionscript 3 - Flash -> ByteArray -> AMFPHP -> Invalid Image? - Stack Overflow

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 08, 2018 0