#!/usr/bin/perl -w
# Perl Upload
# use lib
use strict;
use CGI::Pretty;
# limit 1000K bytes post, permit upload
$CGI::POST_MAX = 1024 * 1000;
$CGI::DISABLE_UPLOADS = 0;
# init variables
my $cgi = new CGI;
my $title = "Perl Upload";
if (!$cgi->param()) {
# print header
print $cgi->header(),
$cgi->start_html($title);
print $cgi->center($cgi->h1($title)),
$cgi->hr(),
$cgi->br();
# print body
print $cgi->center
(
$cgi->start_multipart_form(),
$cgi->font("Filename :"),
$cgi->filefield(-name=>"filename", -size=>"30"),
$cgi->br(),
$cgi->br(),
$cgi->submit(-value=>"Upload"),
$cgi->reset(-value=>"Clear"),
$cgi->end_form()
);
exit(0);
} else {
# get file data
my $file = $cgi->param("filename");
my @filedata = <$file>;
foreach (@filedata) {
s/ s/>/>/g;
s/\n/
\n/g;
}
# print header
print $cgi->header(),
$cgi->start_html($title);
print $cgi->center($cgi->h1($title)),
$cgi->hr(),
$cgi->br();
# print body
print $cgi->h3("$file :
\n"),
"@filedata";
exit(0);
}
0
Test upload script using perl
Test upload script using perl
Wednesday, November 7, 2007
Posted in: Test script | 0 Comments | Email This
Subscribe to:
Post Comments (RSS)
0 Responses to "Test upload script using perl"
Post a Comment