Sunday, February 1, 2009

How to Upload file on server in Perl-Cgi

Basic method of file uploading on server in perl-cgi



#!/usr/bin/perl
use CGI;
$cgi = new CGI;
$file = $cgi->param('file');
@fname=split(/\\/,$file);
$name=$fname[$#fname];
$fl=$cgi->upload('file');
open(FH, ">/var/www/html/uploads/$name");
#binmode FH;
while(<$fl>) {
print FH;
}
print $cgi->header();
print "$name and $file has been successfully uploaded... thank you.\n";

No comments:

Post a Comment