Syntax for POST processing via CGI?

Bill Marriott wjm at wjm.org
Sat Jan 10 12:52:46 EST 2009


Thanks so much, Mark!

That worked; much easier than I thought... though the return from stdin is 
more like:

> -----------------------------7d92ce191e091a
> Content-Disposition: form-data; name="FirstName"
>
> Bill

and not the value/parameter pairs you get from a GET. I wonder what the 
number in the first line signifies (it's not the value specified in the 
$UNIQUE_ID global).

It's interesting how a binary upload is handled... I get:

> -----------------------------7d92ce191e091a
> Content-Disposition: form-data; name="FileUpload"; filename=""
> Content-Type: application/octet-stream

followed by a variety of stuff depending on what kind of document I've 
submitted. It doesn't look like it's Mime (or Base64 encoded), and it's 
nowhere near the full number of bytes in the file. I might also note that 
uploading is considerably slower than, say, PHP -- a 20K JPG took more than 
two minutes. Is this something to do with the way the data is being read?

What's the magic in handling a file upload? (Again, bare-bones.)

FWIW I think I'll put this together in an article for the next revUp 
newsletter.

- Bill

"Mark Smith" wrote:

> on startup
>    put postData() into tPostData
>    split tPostData by "&" & "="
>    -- postData is now an array of the form data
>
> end startup
>
> function postData
>    put empty into tData
>    put 0 into c
>    repeat while tData is empty and c < 20
>       read from stdin until empty
>       put it after tData
>       add 1 to c
>       wait 20 millisecs
>    end repeat
>    return tData
> end postData
>
>
> note that it reads from stdin repeatedly until it's got something -  for 
> some reason, the data doesn't always appear straight away.
>
> On 10 Jan 2009, at 14:42, Bill Marriott wrote:
>
>> anyone have a
>> bare-bones script for processing POST submissions with CGI 






More information about the use-livecode mailing list