One more question about Rev cgi & binary data

jbv jbv.silences at club-internet.fr
Sat Apr 26 12:56:52 EDT 2008



Richard,

Thank for the script, but your method implies the use of a cgi
stack... what if a plain text script is used ?
Actually, I'm looking towards a php solution right now...

Best,
JB

> JB,
>
> Here's the solution which works for me. I know it seems a bit
> bizarre. It took many attempts to figure out how to get it to work
> reliably. But this works all the time.
>
> Best,
> Richard Miller
>
> ---------------------------
>   -- buffer has the incoming data stream
>    put buffer into temp
>    put empty into pictfile
>    put offset("image/jpeg",temp) into xx
>    if xx <> 0 then
>      put xx+14 into xx
>      put char xx to (the length of temp) of temp into pictdata
>      put char 1 to xx-1 of temp into tdata
>      repeat with i = the length of pictdata down to 1
>        if chartonum(char i of pictdata) is 0 then
>          put i into holdit
>          exit repeat
>        end if
>      end repeat
>      delete char (holdit+1) to the length of pictdata of pictdata
>      put "binfile:TempPict_" & the milliseconds & ".jpg" into PictFile
>     -- these next steps are critical. It doesn't work otherwise.
> Field "temp2" is just an empty text field on the cgi stack
>      put pictdata into url PictFile
>      put url PictFile into pictdata
>      put pictdata into fld "temp2"
>      put fld "temp2" into url PictFile
>
> The file PictFile will now be a regular jpeg file you can read and
> manipulate as you would any jpeg file




More information about the use-livecode mailing list