I'm working on a script to upload a file using the "file" type in late model browsers. 
I started with the general example in the How-To Guide ("CGI Post Method") but found 
that the content-length seems to vary between calls. First it tells me the content is 
6229 bytes long, then I repeat the same call and the content is 6291 bytes, then 6299, 
6303, et al. 

Here's as far as I got. Given a good file read, I was next going to parse out the HTML 
and write to a file. Here, I just dump to the file. 

#!/usr/bin/rebol -cs
REBOL[]
;- make variables
intBuffer: make integer! 2000
intContent: make integer! system/options/cgi/content-length
intCursor: make integer! 0
strBuffer: make string! intContent
fooLocation: make file! %/home/httpd/incoming/test.htm 
;- begin
;- read file into buffer
while [ intCursor < intContent ] [
 read-io system/ports/input strBuffer intBuffer
 intCursor: add intCursor intBuffer
]
;- print values for debugging
 print "Content-type: text/plain^/^/"
 print [ "Content-length: " intContent ] 
;- process file
 print strBuffer

;- end
quit

SAMPLE HTML FORM

<HTML><BODY><P>&nbsp;</P>
<FORM 
 METHOD="post" 
 ACTION="/cgi-bin/upload.r" 
 NAME="form1" 
 ENCTYPE="multipart/form-data"
>
<INPUT 
 TYPE="file" 
 NAME="file_name"
>
<INPUT
 TYPE="Submit"
 NAME="Submit"
 VALUE=" Submit "
>
</FORM>
<P>&nbsp;</P></BODY></HTML>




-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Tel 716 425-0252; Fax 716 223-2506.
-- http://www.husted.com/

Reply via email to