Hi,

I have a PHP script that is generating an image based on values passed
to the script using jQuery Ajax functionality. Here is the important
part of the PHP script;

header('Content-Type: image/jpeg');
imagejpeg($image, 'images/tmp/admin.preview.jpg');
imagedestroy($image);

I can get the image to display just fine without using Ajax. I would
prefer not to store the image locally on the server, but instead have
the preview image display temporarily in memory. I have the following
jQuery code implemented that sends the form data to the PHP script,
which generates the dynamic image for preview using jpeg image
stream.

$(document).ready(function()
{
        var options = {
                target:     '#preview-wrapper',
                type:           'post',
                cache:          false,
                url:        'admin.preview.php', // return raw jpeg stream (see
above php code)
                success:    function(html) {
                        // attempted creating an image tag, then pointing to 
the php script
directly. Neither works properly.
                }
        };

        // pass options to ajaxForm
        $('#formAdmin').ajaxForm(options);

});


Hopefully someone can help answer the following questions;
1) What is the best way to accomplish this task? (i.e. return image
stream, return HTML image tag pointing to the locally stored jpeg,
etc...)
2) Could someone help me with the jQuery code?

Thanks in advance for any help or direction.

Reply via email to