According to Geoff Hutchison:
> At 6:46 PM -0800 11/14/01, Stephen L Arnold wrote:
> >Come to think of it, I promised to contribute that script a while
> >back; who should I send it to?  The guy who wrote it isn't into
> >supporting it, but he's okay with me sending it in.  It's not that
> >cryptic (as far as perl goes, anyway).  Let me know...
> 
> E-mail it to the list. Unforunately, we no longer have an FTP server 
> through SourceForge, so e-mail is probably the easiest way to submit 
> things. Although if someone knows how to get those "Browse File" web 
> forms to work with appropriate CGIs, please contact me. :-)

I've always wondered this myself, so I did some searches and read up
a bit.  A lot of HTML tutorials out there don't mention file input in
forms, which was an extension to HTML 3.0, but became standard in 3.2.
Here are a couple references that tell you what to do at the form end,
and what happens behind the scenes:

http://MasterCGI.com/howtoinfo/formtutorial.shtml
http://www.faqs.org/rfcs/rfc1867.html

Essentially, you have a form something like:

  <form method="post" action="/cgi-bin/getfile" enctype="multipart/form-data">
    <input type="file" size="30" name="myfile" accept="text/plain">
    <input type="text" size="30" name="description" value="">
    <input type="submit" value="Upload">
  </form>

The trick is to write a CGI program that handles the multipart/form-data
encoding type that's needed for file input.  In addition to the
REQUEST_METHOD and CONTENT_LENGTH environment variables you're used to
dealing with for POST requests, you also have something like:

CONTENT_TYPE=multipart/form-data; 
boundary=---------------------------1418534810405220191815508293

And the data read from stdin will look something like:

-----------------------------1418534810405220191815508293
Content-Disposition: form-data; name="myfile"; filename="t.txt"
Content-Type: text/plain

line 1
line 2
...
last line

-----------------------------1418534810405220191815508293
Content-Disposition: form-data; name="description"

description line
-----------------------------1418534810405220191815508293--

I haven't actually written any code to deal with this, but I'd bet that
the Perl CGI.pm can already handle this encoding type.

-- 
Gilles R. Detillieux              E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

_______________________________________________
htdig-general mailing list <[EMAIL PROTECTED]>
To unsubscribe, send a message to <[EMAIL PROTECTED]> with a 
subject of unsubscribe
FAQ: http://htdig.sourceforge.net/FAQ.html

Reply via email to