upload_ruby.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>upload ruby (Apr/12/2021)</title>
</head>
<body>
<h2>HTML5</h2>
<form method="post" action="upload_ruby.rb" enctype="multipart/form-data">
<input type="file" name="files" multiple>
<p><input type="submit" value="送信する"></p>
</form>
<blockquote>
<p>File is uploaded to ./data_work.</p>
<p>複数のファイルのアップロードができない。</p>
</blockquote>
<hr />
Apr/12/2021 AM 08:25<p />
</body>
</html>
upload_ruby.rb
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
#
# upload_ruby.rb
#
# Apr/12/2021
#
# --------------------------------------------------------------------
require "cgi"
# --------------------------------------------------------------------
form = CGI.new
print "Content-type: text/html\n\n"
print "Now Uploading...<br />"
print form.keys
print "<br />"
print form.params
print "<br />"
print "*** aaaa ***<br />"
print form['files']
print "<br />"
print form['files'].length
print "<br />"
print form['files'].class.to_s + "<br>"
print form['files'].original_filename + "<br>"
#
#
output_dir = "./data_work"
open(output_dir + "/" + form['files'].original_filename, "w") {|fh|
fh.write form['files'].read
}
#
print "Upload End"
# --------------------------------------------------------------------