views:

620

answers:

1

I am facing the task of having to upload a snapshot to the server. But I don't want the user to download the image to their computer.

I have explored a few solutions of generating an image serverside with PHP, but they all seem to use a method where the server sends the image to the user.

See for instance: http://mattkenefick.com/blog/2008/11/06/saving-jpegs-with-flash/

I'm wondering if it's possible to save $GLOBALS["HTTP_RAW_POST_DATA"], which in that example contains the ByteArray sent by Flash, to the server as an image file....

+2  A: 

Use php code that is along these lines to save the contents of $GLOBALS["HTTP_RAW_POST_DATA"]

        // untested code

        $imageBytes = $GLOBALS["HTTP_RAW_POST_DATA"]
        // in real code you better create a new file for every upload :-)
        $file = fopen("uploads/test.jpg", "w");
        if(!fwrite($file, $imageBytes)){
            return "Error writing to file: $file";
        }
        fclose($file);
Simon Groenewolt
That worked great. Thanks.
picardo