Willman023 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -wT use strict; use CGI qw(:standard); print "Content-Type: text/html\n\n"; my $file = param ('uploadfile'); my $info = uploadInfo ($file); my $type = $info -> {'Content-Type'}; my $name = param ('name'); my $course = param ('course'); my $lastname = param ('lastname'); my $term = param ('term'); my $description = param ('description'); my $filename = "$name$course$lastname$term$description"; if ($file) { open (UPLOAD, ">/var/www/uploads/$filename") || Error (); my ($data, $length, $chunk); while ($chunk = read ($file, $data, 1024)) { print UPLOAD $data; $length += $chunk; if ($length > 5120000) { print "That file is too big. The limit is 5 Megs."; exit; } } close (UPLOAD); print "<p>You uploaded <b>$file</b> which had a MIME type of <b>$t +ype</b>."; print "<p>Your filename is <b>$filename</b>."; } else { print "No file was chosen."; } sub Error { print "Couldn't open temporary file: $!"; exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Upload problem
by ajt (Prior) on Oct 01, 2001 at 13:28 UTC | |
by Willman023 (Scribe) on Oct 04, 2001 at 08:32 UTC | |
|
Answer: Upload problem
by Hero Zzyzzx (Curate) on Oct 01, 2001 at 20:49 UTC | |
by Willman023 (Scribe) on Oct 04, 2001 at 08:36 UTC |