I am trying to save some images from Flash to Php by sending a jpgstream, capturing it in php and pushing it to a file. Not sure what I am doing wrong here.
I am putting all the images I need into an array like so: (history is just where I am keeping all the image data)
for each($value in history)
{
var jpgSource:BitmapData = new BitmapData ($value.sourceImg.width, $value.sourceImg.height);
jpgSource.draw($value.sourceImg);
var encoder:JPEGEncoder = new JPEGEncoder(100);
var jpgStream:ByteArray = encoder.encode(jpgSource);
var imgDetailArr:Array = new Array(jpgStream, $value.name);
imgArr.push(imgDetailArr);
}
And then i send that to PHP using a remote object and amfphp:
rmObj.saveUserImages( imgArr);
On the php side I am doing this:
function saveUserImages( $imgArr)
{
foreach($imgArr as $value)
{
ob_start();
/* output image as JPEG */
$image = imagecreatefromjpeg($value[0]);
header('Content-type: image/jpeg');
imagejpeg( $image );
/* save output as file */
ob_flush();
file_put_contents( "images", ob_get_contents() );
}
}
But this doesn't seem to do the trick. I have been going through a bunch of different tutes and code snippets, so maybe I just ogt something confused along the way. I have done this before though and don't remember it being this difficult.