On Mon, Jan 13, 2003 at 10:50:24PM +0900, Jim Freeze wrote:
> I have searched the archives and posted this message three times
> and have yet to get a response. I am trying to create a web page
> that let's a user upload a file.

OK, I felt sorry for you and looked in too it just now (but I
had already deleted your mail, so I high-jacked another one from
you, possibly upsetting people's threading mail-clients, inserting
the contents of your original posting from the mailinglist archive).

> I have worked through most of the issues, and can even get
> a file on to my server, but it is embedded in a binary file
> whose format is unknown.
> Has anyone experience with this, or is there documentation on
> how to extract the file data from what is sent to the server?
> Below is an example of the file I get from webrick.
> The original contents of the file v.rb is "This is a test.\n"

The spooky data is a boundary, which also is submitted via the
CONTENT_TYPE environment variable.

Test the following html-file (invalid, lacks head, body, and such):
--
<form action="env.rb" method="post" ENCTYPE="multipart/form-data">
  <input type="file" NAME="filename" ACCEPT="text/html">
  <input type="submit">
</form>
--

with this ruby-snipet as the responding cgi action[1]:

env.rb
--
#!/usr/bin/ruby -w

puts "Content-type: text/html\n\n";

puts "--START--<br>\n";

while line = gets()

        puts line;
end

puts "<br>--STOP--<br>\n";

ENV.each_pair { |e, v|

        puts "#{e} = #{v}<br>\n";
}
--

Look especially at the value of CONTENT_TYPE. Is it not that boundary
that comes before and after the actual contents of the file you chose
to upload?

Best Regards /Selander

[1] I hope your web-server supports Ruby-cgi:s. If not, try to 
    experiment with the directive "AddType application/x-httpd-cgi .rb"
    in an own .htaccess file, if the server allows that. It, of course,
    still requires that the web-server have Ruby installed, but it 
    should be possible to have it installet in your own home directory
    and direct the shebang-line to it. Just don't tell your sysadmin or
    he might consider it as an violation of security.
-- 
Anders Selander   Centre for Parallel Computers   selander / pdc.kth.se
Programmer        Royal Institute of Technology   +46 (0)8  790 72 11
                  SE-100 44  STOCKHOLM, SWEDEN    +46 (0)70 266 29 67