Perlコーディング初心者質問スレ Part 56at PHP
Perlコーディング初心者質問スレ Part 56 - 暇つぶし2ch775:nobodyさん
08/01/19 23:16:40
#!/usr/bin/env perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use POSIX qw(strftime);
my $q = new CGI;
print $q->header(), $q->start_html();
#print $q->dump; # for debug
my $outputdir = "log"; # ファイルを置く先 (ディレクトリ)
my $fh = $q->param('uploaded_file');
my ($ex) = ($fh =~ m|(\.[^./\\]+)$|); # 拡張子
if ($fh ne "") {
my $timestamp = strftime "%y%m%d%H%M%S", localtime;
my $outputfn = "$outputdir/$timestamp$ex";
open(F, "> $outputfn") or die;
flock(F, 2);
if (defined $fh) {
while (<$fh>) {
print F $_;
}
}
close F;
print qq{saved as <a href="$outputfn">$outputfn</a>};
}
print $q->start_multipart_form(-name => 'myform'),
$q->filefield(-name => 'uploaded_file'),
$q->submit("OK"),
$q->endform,
$q->end_html(), "\n";


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch