#!/usr/bin/perl use CGI; use IO::File; use POSIX; use strict; my $cgi = CGI->new; # temporary file name is supplied by POSIX::tmpnam function my $buffer; my $tmpfile = POSIX::tmpnam; # loop through CGI handle and write new temporary file my $fh = IO::File->new(">".$tmpfile); print $fh $buffer while (read($cgi->param('inputfile'), $buffer, 1024) +); $fh->close; # retrieve file name from CGI file field parameter my $newfile = ($cgi->param('inputfile') =~ /^((?:.*[:\\\/])?)(.*)/s)[1 +]; # rename file unless file exists rename $tmpfile, $newfile unless -e $newfile; # return HTML headers and page data . . exit 0;
Ooohhh, Rob no beer function well without!
In reply to Re: Re: Re: Uploading files (total newbie needs help...)
by rob_au
in thread Uploading files (total newbie needs help...)
by guth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |