aaa
test01.txt
test01.html
test01.cgi
http://www6.atpages.jp/aurora72source2/cgi/test005/ls01.html
http://www6.atpages.jp/aurora72source2/cgi/test005/upload.html
http://www6.atpages.jp/aurora72source2/cgi/test005/test01.html
aaa
<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="ja">
<head>
<title>アップロード用フォーム</title>
</head>
<body>
<h1>アップロード用フォーム</h1>
<form action="upload.cgi" method="post"
enctype="multipart/form-data">
<p>
updir(Remote):
<input type="text" name="updir"><BR></p>
<p>
localdir(Localdir):
<input type="text" name="localdir"><BR></p>
<p>upfile:</p>
<p><input type="file" name="filename01" /></p>
<p><input type="text" name="filename02" /></p>
<p>Mode(例:0700):
<input type="text" name="filemode"><BR></p>
<p>
<input type="submit" value="送信" />
<input type="reset" value="リセット" />
</p>
</form>
</body>
</html>
#!/usr/local/bin/perl -w
# モジュール読み込み
use strict;
use CGI;
my ($buffer);
# オブジェクト作成
my $query = new CGI;
# $f = $_POST['filename'];
my $filename = $query->param('filename02');
my $filemode = $query->param('filemode');
# ファイル取得
my $fH = $query->upload('filename01');
# MIMEタイプ取得
my $mimetype = $query->uploadInfo($fH)->{'Content-Type'};
# HTML出力
print $query->header(-charset=>'Shift_JIS'),
$query->start_html(-lang=>'ja', -encoding=>'Shift_JIS',
-title=>'upload.cgi');
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
open(IN, "ls -alt ./ |");
while (<IN>) {
print $_;
print '<BR>';
}
close(IN);
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
# $cmd01 = "cp -a ./tmpfile $filename |";
# print("$cmd01<br>\n");
open(IN, "cp -apbf ./tmpfile $filename | ");
while (<IN>) {
print $_;
print '<BR>';
}
close(IN);
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
open(IN, "ls -al ./ |");
while (<IN>) {
print $_;
print '<BR>';
}
close(IN);
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
# ファイル保存
# open (OUT, ">Savefile") || die "Can't open Savefile!";
open (OUT, ">$filename") || die "Can't open Savefile!";
binmode (OUT);
while(read($fH, $buffer, 1024)){
print OUT $buffer;
}
close (OUT);
close ($fH) if ($CGI::OS ne 'UNIX'); # Windowsプラットフォーム用
chmod ("$filemode", "$filename");
print <<"HTML_VIEW";
<h1>ファイルアップロード</h1>
<ul>
<li>ファイル名:$fH</li>
<li>MIMEタイプ:$mimetype</li>
</ul>
<p>ファイルのアップロードが完了しました。</p>
HTML_VIEW
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
open(IN, "ls -alt ./ |");
while (<IN>) {
print $_;
print '<BR>';
}
close(IN);
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
open(IN, "ls -al ./ |");
while (<IN>) {
print $_;
print '<BR>';
}
close(IN);
print("===========================================<br>\n");
print("===========================================<br>\n");
print("===========================================<br>\n");
print $query->end_html;
exit;
aaa