Thread Perl Upload Script (27 answers)
Opened by willy168 at 2011-08-09 10:40

rosti
 2011-08-10 10:58
#151443 #151443
User since
2011-03-19
3219 Artikel
BenutzerIn
[Homepage]
user image
Try this:


Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use CGI qw(-utf8);
$CGI::POST_MAX = 40_000_000;
use File::Copy;
use File::Basename;
my $c = CGI->new;

if($c->param){
        print $c->header(-charset => 'utf-8'), $c->h2('Result');

        my $fh = $c->param('upfile');      # Get the FileHandle from temp-File
        my $source = $c->tmpFileName($fh); # get the source filename
        my $dest = $fh;                    # scalar context, origin filename from UserAgent
        my $ref = [fileparse($dest)];      # Dateiname in [0]
        print "Copy $source, /tmp/$ref->[0]";
        copy $source, "/tmp/$ref->[0]";
}

View full thread Perl Upload Script