sending JPG bytes to a PHP script via POST?
sending JPG bytes to a PHP script via POST?
am 13.11.2007 01:59:32 von joshuajnoble
Hi all, I'm working with a flash application that sends a small JPEG
as binary data over a post to a PHP script. I'd like the script to be
able to display that JPEG but I've tried imagecreatefromstring without
any luck and looked through the documentation without much luck. The
data getting sent to the PHP script is a valid JPEG file, but I'm not
sure what to do with it once it gets there. Is there a way to do this,
or is there a better way to do it, or is this not possible? Thanks for
any advice or hints.
Re: sending JPG bytes to a PHP script via POST?
am 13.11.2007 02:05:33 von darko
On Nov 13, 1:59 am, joshuajnoble wrote:
> Hi all, I'm working with a flash application that sends a small JPEG
> as binary data over a post to a PHP script. I'd like the script to be
> able to display that JPEG but I've tried imagecreatefromstring without
> any luck and looked through the documentation without much luck. The
> data getting sent to the PHP script is a valid JPEG file, but I'm not
> sure what to do with it once it gets there. Is there a way to do this,
> or is there a better way to do it, or is this not possible? Thanks for
> any advice or hints.
Are you sure you have post the question right? Because this way it
looks as if
you have the picture on the client, then you send it to server, and
then you
expect the script to return an image in response? All that by POST
method?
Where do you get that image from on the client?
Never mind. If you want to display an image from PHP, you do something
like this:
header( "Content-Type: image/jpeg" ); // jpeg in your case
$imageData = ...; // you get this data somehow, from POST or
whatever you imagine it like
echo $imageData;
?>
That is it. The key is in header function, i.e. in Content-Type.
Regards
Re: sending JPG bytes to a PHP script via POST?
am 13.11.2007 03:21:39 von joshuajnoble
The image is generated in the Flash Player and then sent to the
script. There must be something wrong with the data then because all
that I see returned in the browser when I tried to do that earlier I
saw:
ÿÃÿ=C3
So...not quite what I was hoping for :)
On Nov 12, 10:05 pm, Darko wrote:
> On Nov 13, 1:59 am, joshuajnoble wrote:
>
> > Hi all, I'm working with a flash application that sends a small JPEG
> > as binary data over a post to a PHP script. I'd like the script to be
> > able to display that JPEG but I've tried imagecreatefromstring without
> > any luck and looked through the documentation without much luck. The
> > data getting sent to the PHP script is a valid JPEG file, but I'm not
> > sure what to do with it once it gets there. Is there a way to do this,
> > or is there a better way to do it, or is this not possible? Thanks for
> > any advice or hints.
>
> Are you sure you have post the question right? Because this way it
> looks as if
> you have the picture on the client, then you send it to server, and
> then you
> expect the script to return an image in response? All that by POST
> method?
> Where do you get that image from on the client?
>
> Never mind. If you want to display an image from PHP, you do something
> like this:
>
> header( "Content-Type: image/jpeg" ); // jpeg in your case
> $imageData =3D ...; // you get this data somehow, from POST or
> whatever you imagine it like
> echo $imageData;
> ?>
>
> That is it. The key is in header function, i.e. in Content-Type.
>
> Regards
Re: sending JPG bytes to a PHP script via POST?
am 13.11.2007 03:35:34 von Jerry Stuckle
joshuajnoble wrote:
> On Nov 12, 10:05 pm, Darko wrote:
>> On Nov 13, 1:59 am, joshuajnoble wrote:
>>
>>> Hi all, I'm working with a flash application that sends a small JPEG
>>> as binary data over a post to a PHP script. I'd like the script to be
>>> able to display that JPEG but I've tried imagecreatefromstring without
>>> any luck and looked through the documentation without much luck. The
>>> data getting sent to the PHP script is a valid JPEG file, but I'm not
>>> sure what to do with it once it gets there. Is there a way to do this,
>>> or is there a better way to do it, or is this not possible? Thanks for
>>> any advice or hints.
>> Are you sure you have post the question right? Because this way it
>> looks as if
>> you have the picture on the client, then you send it to server, and
>> then you
>> expect the script to return an image in response? All that by POST
>> method?
>> Where do you get that image from on the client?
>>
>> Never mind. If you want to display an image from PHP, you do something
>> like this:
>>
>> header( "Content-Type: image/jpeg" ); // jpeg in your case
>> $imageData = ...; // you get this data somehow, from POST or
>> whatever you imagine it like
>> echo $imageData;
>> ?>
>>
>> That is it. The key is in header function, i.e. in Content-Type.
>>
>> Regards
>
>
>
> The image is generated in the Flash Player and then sent to the
> script. There must be something wrong with the data then because all
> that I see returned in the browser when I tried to do that earlier I
> saw:
>
> ÿÃÿÃ
>
> So...not quite what I was hoping for :)
>
(Top posting fixed)
How are you trying to generate the image? Some code would help...
P.S. Please don't top post. Thanks.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: sending JPG bytes to a PHP script via POST?
am 13.11.2007 03:47:27 von nc
On Nov 12, 4:59 pm, joshuajnoble wrote:
>
> I'm working with a flash application that sends a small JPEG
> as binary data over a post to a PHP script. I'd like the script
> to be able to display that JPEG but I've tried imagecreatefromstring
> without any luck and looked through the documentation without
> much luck. The data getting sent to the PHP script is a valid
> JPEG file, but I'm not sure what to do with it once it gets there.
The issue here is that the PHP script that generates an image
dynamically cannot generate HTML and vice versa. I would guess that
the script that receives data from the Flash application generates
some HTML, so it cannot generate the image. You need to do one of the
following:
1. Write the JPEG image to disk and generate HTML with tag
pointing to the newly created file.
2. Pass the JPEG image data to another script, which will render
it as image. Given the relatively large chunk of data that
needs to be passed, consider using a session variable.
Cheers,
NC
Re: sending JPG bytes to a PHP script via POST?
am 13.11.2007 04:36:42 von joshuajnoble
On Nov 12, 11:47 pm, NC wrote:
> On Nov 12, 4:59 pm, joshuajnoble wrote:
>
>
>
> > I'm working with a flash application that sends a small JPEG
> > as binary data over a post to a PHP script. I'd like the script
> > to be able to display that JPEG but I've tried imagecreatefromstring
> > without any luck and looked through the documentation without
> > much luck. The data getting sent to the PHP script is a valid
> > JPEG file, but I'm not sure what to do with it once it gets there.
>
> The issue here is that the PHP script that generates an image
> dynamically cannot generate HTML and vice versa. I would guess that
> the script that receives data from the Flash application generates
> some HTML, so it cannot generate the image. You need to do one of the
> following:
>
> 1. Write the JPEG image to disk and generate HTML with tag
> pointing to the newly created file.
>
> 2. Pass the JPEG image data to another script, which will render
> it as image. Given the relatively large chunk of data that
> needs to be passed, consider using a session variable.
>
> Cheers,
> NC
Ok, makes sense, thank you kindly for the advice.
J
Re: sending JPG bytes to a PHP script via POST?
am 13.11.2007 16:49:10 von Bucky Kaufman
"joshuajnoble" wrote in message
news:1194915572.316182.224350@d55g2000hsg.googlegroups.com.. .
> Hi all, I'm working with a flash application that sends a small JPEG
> as binary data over a post to a PHP script. I'd like the script to be
> able to display that JPEG but I've tried imagecreatefromstring without
> any luck and looked through the documentation without much luck. The
> data getting sent to the PHP script is a valid JPEG file, but I'm not
> sure what to do with it once it gets there. Is there a way to do this,
> or is there a better way to do it, or is this not possible? Thanks for
> any advice or hints.
The way I would do it is to binhex the data and include it inline with the
IMG tag.
That way, you don't have to save the fragment to a file.