[REBOL] Re: How to file upload via http?
From: andreas:bolka:gmx at: 23-Aug-2002 17:40
Friday, August 23, 2002, 12:38:09 AM, Jason wrote:
> Can you help me understand how to use it?
-- snip --
; first you fetch the post-data (the HTTP POST entity body,
; to be correct) as always
len: load any [ system/options/cgi/content-length "0"]
post-data: make string! (len + 10)
while [len > 0][ len: len - read-io system/ports/input post-data len ]
; then this POST-data can be handed over to decode-multipart-form-data
; (if it is encoded according to the mime multipart RFC's as
; indicated by a content type beeing multipart/form-data)
tmp-post: either found? find any [ system/options/cgi/content-type "" ] "multipart/form-data"
[ decode-multipart-form-data system/options/cgi/content-type post-data ]
[ decode-cgi post-data ]
-- snap --
after that you'll have a decode-cgi like structure in tmp-post which
is described in full detail in the headers of the script i posted
before:
-- snip --
Purpose: {
Decodes POST-data encoded as "multipart/form-data" as defined by
RFC 2388.
The output is compatible to 'decode-cgi wherever possible. So the
output contains a list of set-word's and values, one pair for each data
field. example:
[ field1: "foo" field2: "bar" ]
If the content type of one part of the form-data is not equal to
text/plain, then the value of the respective mime-part is an
object! with the following attribs: filename, type, content. example:
[ field1: "foo"
field2: make object! [
filename: "user.xml"
type: "text/xml"
content: "<?xml version='1.0'><user />"
]
]
}
-- snap --
--
Best regards,
Andreas mailto:[andreas--bolka--gmx--net]