dinput.cgi
#!/usr/bin/perl
BEGIN { $ 1 = ; print “Content-type: text/html\n\n”; open(STDERR,
“>& STDOUT”);}
use CGI
;$query=new CGI;
# ファイル名の取得
$filename = $ query->param(‘upload_file’);
if($filename ! ~ m/\.jpg$/)
{die”画像ファイルが適応しておりませ ん。jpgファイルでお願いします。”;}
####### 画像MIMEタイプの取得
$type=$query->uploadInfo($filename)->{‘Content-Type’);
while($bytesread = read($filename,$buffe,2048)){
$file.=$buffer;
}
#画像の名前をアクセスタイムから取得##################
local($nsec,$nmin,$nhour,$nmday,$nmon,$nyear)=localtime(time);
$nmon++;
$nyear+=1900;
$gazouname=”$nyear$nmon$nmday$nhour$nmin$nsec”;
$day=”$nyear/$nmon/$nmday”;
$gazou=”$gazouname.jpg”;
#外部ファイルに書き込む##################
画像ファイルの保存##################################
open(OUT,”> images/$gazou”)ordie(“ファイルの保存に失敗しました”);
binmode(OUT);
print(OUT $file);
close(OUT);
#######################################################
$name = $query->param(‘name’);
$category = $query->param(‘category’);
##################################
#外部ファイルに書き込む##################
@data=”$day\t$name\t$category\t$gazou\n”;
open(FILE,”>>save.txt”)||&error(“$datafile 外部ファイルが開きませんでしたエラー”);
print FILE @data;
close(FILE);
######################################
print <<END;
<html>
<head>
<title>フォトデータベース input</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=Shift_JIS”>
</head>
<body bgcolor=”#FFFFFF” text=”#000000″>