|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 ================== |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
"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. |
|
![]() |
| Outils de la discussion | |
|
|