Hi
I created a form wich allows to select a file and send it to the server
:
-----------------
class FormHandler < Mongrel::HttpHandler
def process(req, resp)
resp.start do |head, body|
body << "<html>"
body << "<body>"
body << "<form name=""formulaire_envoi_fichier""
enctype=""multipart/form-data"" method=""post"" action=""./test"">"
body << "<input type=""file"" name=""fichier_choisi"">"
body << "<br>"
body << " <br>"
body << " <input type=""submit"" name=""bouton_submit""
value=""Envoyer le fichier"">"
body << "</body>"
body << "</html>"
end
end
end
class MyHandler < Mongrel::HttpHandler
attr_accessor :responses_file
def initialize
end
def process(req, resp)
resp.start do |head, body|
puts "Req.inspect",req.inspect
puts "Req params",req.params
i=0
req.body.each_line do |l|
puts l
end
puts
print i," lignes"
body.write("<html>");
body.write(" <head>");
body.write(" <title>Test Page</title>");
body.write(" </head>");
body.write(" <body>");
...
body << "</body></html>"
end
end
end
h = Mongrel::HttpServer.new("0.0.0.0", "3000")
h.register("/test", MyHandler.new)
h.register("/acc",FormHandler.new)
h.run.join
end
---------------
Then when I run in the test page
http://localhost:3000/test, I can see
the content of the file in the request's body (puts l). But I don't know
how to extract this data.