dinput.cgi
#!/usr/bin/perl
BEGIN{ $| = 1; print “Content-type: text/html\n\n”; open(STDERR, “>&STDOUT”); }
use CGI;
$query = new CGI;
# t @ C ̎擾
$filename = $query->param(‘upload_file’);
if($filename !~m/\.jpg$/)
{die” 摜 t @ C K Ă ܂ Bjpg t @ C ł 肢 ܂ B”;}
####### 摜 MIME ^ C v ̎擾
$type = $query->uploadInfo($filename)->{‘Content-Type’};
while($bytesread = read($filename, $buffer, 2048)) {
$file .= $buffer;
}
# 摜 ̖ O A N Z X ^ C 擾##################
local($nsec,$nmin,$nhour,$nmday,$nmon,$nyear)=localtime(time);
$nmon++;
$nyear+=1900;
$gazouname=”$nyear$nmon$nmday$nhour$nmin$nsec”;
$day = “$nyear/$nmon/$nmday”;
$gazou = “$1.jpg”;
# O t @ C ɏ #################
# 摜 t @ C ̕ۑ ##################################
open(OUT, “> images/$gazou”) or die(” t @ C ̕ۑ Ɏ s ܂ B”);
binmode(OUT);
print(OUT $file);
close(OUT);
#######################################################
$name = $query->param(‘name’);
$category = $query->param(‘category’);
##################################
# O t @ C ɏ ##################
@data=”$day\t$name\t$category\t$gazou\n”;
open(FILE,”>>save.txt”)||&error(“$datafile O t @ C J ܂ ł G [“);
print FILE @data;
close(FILE);
######################################
print <<END;
<html>
<head>
<title> t H g f [ ^ x [ X input</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=Shift_JIS”>
</head>
<body bgcolor=”#FFFFFF” text=”#000000″>
<div align=”center”>
<h1><b> t H g f [ ^ x [ X </b></h1>
</div>
<hr>
f [ ^ ۑ ܂ B<br>
END
print”<img src =\”images/$gazou\” width=\”200px\” height=\”auto\”>\n”;
print”</body></html>\n”;