Webrick upload file issue

N

name pipe

Hello,

Is there any feature in webrick using which we can upload our files
directly. I am talking about the files which are submitted using
<input type="file"> tag.

Thanks
 
J

Jan Svitok

Can anyone help me on this ?

Try using cgi lib, http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html

Get multipart form values

require "cgi"
cgi = CGI.new
value = cgi['field_name'] # <== value string for 'field_name'
value.read # <== body of value
value.local_path # <== path to local file of value
value.original_filename # <== original filename of value
value.content_type # <== content_type of value

and value has StringIO or Tempfile class methods.

Now you have to figure out how to connect those two ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,217
Messages
2,571,121
Members
47,724
Latest member
Farreach2565

Latest Threads

Top