I am working with Flash and AS3, implementing an app that generates a JPEG file from a Flash app and downloads it to the user.
Basically, the source comes from here:
http://henryjones.us/articles/using-the-as3-jpeg-encoder
The Flash part is mostly not relevant here -- it generates a bytestream of binary JPEG data, and sends it as binary data to a PHP script in a "_blank" separate browser window. The PHP serves it up as an attachment.
Here is the entire PHP script:
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
// get bytearray
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $im;
} else echo 'An error occured.';
I got this all working perfectly in Firefox. A tabbed window appears temporarily while the File Download box is up; the JPEG file is downloaded; the tabbed window disappears. (No server file is ever created, the binary JPG data goes directly to the attachment of the generated PHP page.)
On IE 6 it doesn't work well. The JPEG data is correctly captured and downloaded
in a JPEG file. But after the JPEG is correctly downloaded, the browser window displays an Action Canceled (No Page to Display) error.
I've looked through various sources for alternatives. I would rather not rebuild it with a much more complex solution involving a temp JPG server file, which would require a system for unique names, file-protections, completion timers, and cleanup of old files, etc.
Any pointers to help make the simple solution work? IE is processing the image fine, before it displays the error. -- I'd like to just suppress the error page generated later.