Hi, Ive been pulling my hair on this one -- who hasnt. Im encoding a jpg using the JPGEncoder and the same code that is out there on the internet.
AS:
PHP:
for some reason, I seem to be the only one in the world who this happens to. About half the time, the image appears as half rendered. Youll see half the stage fine but the other half looks likes its still being drawn out. Ive seen it still green, magenta, gray, all the colors of the rainbow. When I try to load the image in photoshop, it says that the image is corrupted. Im stuck using CS3 for right now, so I still have to bounce downloads off the server. Can anyone offer any insight? I cant tell if its the actual byteArray or if its on the server side. I have no idea where to start to debug this. Please someone help me!
Thanks in advance!!
AS:
Code:
var jpgSource:BitmapData = new BitmapData (sw, sh);
jpgSource.draw(root);
var namae:String = TITLE.replace(/[\s]/g, "-");
var jpgEncoder:JPGEncoder = new JPGEncoder(90);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest(URL+"download.php?name="+namae+".jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "_top");
Code:
if (isset( $GLOBALS["HTTP_RAW_POST_DATA"])) {
$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $jpg;
} else {
echo "An error occured.";
}
Thanks in advance!!