Dave,

Thanks for the code; I'll try that as well, although the problem is not
to parse data from multipart encoded forms, but to keep binary data
consistent inside Rev variables...
I'm probably doing something wrong, but as soon as I use "line" or
"lineoffset" in a script, or even try to count the number of chars,
binary data seem to get corrupted... Probably because the "return" char
is part of the binary data...

JB


>
>
> I've done this before with jpeg files uploaded as binary data. I can't
> find the script I used, but I think the handler below is what I used
> to parse the form data. It's based on a libCGI script that Jacqueline
> Gay used to distribute. It will handle standard and multipart forms.
>
> If you need to find out how the data was encoded (e.g. whether base64
> or binary) then I think you'll need to look for a "Content-transfer-
> encoding:" header somewhere below the boundary for the file part.
>
> Cheers
> Dave
>
> ##########################################
>
> //assumes sPostdata already contains the entire posted data
> // watch for wrapping in the email
>
> local sCGIData, sPostdata
>
> on parsePostData
>         if sPostdata is empty then exit parsePostData
>         if matchText($CONTENT_TYPE,"multipart/form-data;
> *boundary=(.*)",tMimeBoundary) then
>         stripQuotes tMimeBoundary
>
>         put lineOffset(tMimeBoundary,sPostdata) into tStartLine
>         if tStartLine = 0 then exit parsePostdata
>         repeat forever
>                 put lineOffset(tMimeBoundary,sPostdata, tStartLine + 1) +
> (tStartLine + 1) into tEndline
>                 if tEndline < 1 then exit repeat
>                         if matchText(line tStartLine to tEndLine of 
> sPostdata,"Content-
> Disposition: +form-data; +name="&quote&"([^"&quote&"]+)",tName) then
>                                 put lineOffset(CRLF & CRLF, line tStartLine 
> to tEndLine of
> sPostdata) + tStartLine + 1 into tDataOffset
>
>                                 put line tDataOffset to tEndLine - 1 of 
> sPostdata into tValue
>                                 rStripCR tValue
>                                 put tValue into sCGIData[tName]
>                                 put tEndLine into tStartLine
>                         else
>                                 exit repeat
>                 end if
>         end repeat
>      else  ##assume www form urlencoded
>         if sPostdata <> empty then split sPostdata  by "&" and "="
>         repeat for each line tKey in the keys of sPostData
>                 put URLDecode(sPostData[tKey]) into sCGIData[tKey]
>         end repeat
>         end if
> end parsePostData
> _______________________________________________
> use-revolution mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to