PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > sending JPG bytes to a PHP script via POST?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
sending JPG bytes to a PHP script via POST?

Réponse
 
LinkBack Outils de la discussion
Vieux 13/11/2007, 01h59   #1
joshuajnoble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut sending JPG bytes to a PHP script via POST?

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.

  Réponse avec citation
Vieux 13/11/2007, 02h05   #2
Darko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sending JPG bytes to a PHP script via POST?

On Nov 13, 1:59 am, joshuajnoble <joshuajno...@gmail.com> 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:
<?php
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

  Réponse avec citation
Vieux 13/11/2007, 03h21   #3
joshuajnoble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sending JPG bytes to a PHP script via POST?


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

On Nov 12, 10:05 pm, Darko <darko.maksimo...@gmail.com> wrote:
> On Nov 13, 1:59 am, joshuajnoble <joshuajno...@gmail.com> 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:
> <?php
> 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



  Réponse avec citation
Vieux 13/11/2007, 03h35   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sending JPG bytes to a PHP script via POST?

joshuajnoble wrote:
> On Nov 12, 10:05 pm, Darko <darko.maksimo...@gmail.com> wrote:
>> On Nov 13, 1:59 am, joshuajnoble <joshuajno...@gmail.com> 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:
>> <?php
>> 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 ...

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  Réponse avec citation
Vieux 13/11/2007, 03h47   #5
NC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sending JPG bytes to a PHP script via POST?

On Nov 12, 4:59 pm, joshuajnoble <joshuajno...@gmail.com> 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 <img> 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

  Réponse avec citation
Vieux 13/11/2007, 04h36   #6
joshuajnoble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sending JPG bytes to a PHP script via POST?

On Nov 12, 11:47 pm, NC <n...@iname.com> wrote:
> On Nov 12, 4:59 pm, joshuajnoble <joshuajno...@gmail.com> 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 <img> 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

  Réponse avec citation
Vieux 13/11/2007, 16h49   #7
Sanders Kaufman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sending JPG bytes to a PHP script via POST?

"joshuajnoble" <joshuajnoble@gmail.com> wrote in message
news:1194915572.316182.224350@d55g2000hsg.googlegr oups.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.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h52.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13544 seconds with 15 queries