Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: file uploads

From: amicom:sonic at: 29-Aug-2002 9:41

I haven't been following this thread, but I have written HTTP upload scripts for a few sites. Here's an excerpt from one of them that I hope will help. #!/usr/local/bin/rebol/rebol -cs REBOL [] print "Content-type: text/html^/^/" if error? err: try [ input-cgi: func [/local buffer stdin] [ buffer: copy "" either system/options/cgi/request-method = "POST" [ until [ stdin: make string! 4000 read-io system/ports/input stdin 4000 append buffer stdin zero? length? stdin ] return buffer ][system/options/cgi/query-string] ] ;probe <PRE> cgi: replace/all replace/all input-cgi "^J" "^M" "^M^J" "^M" ;probe </PRE> write/append %access.log reform [%batch now system/options/cgi/remote-addr system/options/cgi/query-string newline] query: make object! [] if find cgi "^M^MContent-Disposition:" [replace/all cgi "^M^M" "^M"] while [cgi: find/tail cgi {name="}][ nm: copy/part cgi find cgi {"} cgi: find/tail cgi "^M^M" data: copy/part cgi cgi: find cgi "^M--" query: make query compose [(to-set-word nm) data] ] error? try [write %batch.txt mold query true] ... ][handle-error] It may be a bit of a hack, but it's been getting the job done for the past year or so. Have fun! Bohdan "Bo" Lechnowsky Lechnowsky Technical Consulting At 06:12 AM 8/29/02 -0400, you wrote: