Stamp_Guy has asked for the wisdom of the Perl Monks concerning the following question:
P.S. I realize that this one isn't crossplatform.
#!/usr/bin/perl -T use strict; use CGI qw(:standard upload); use CGI::Carp; use HTML::Entities; print header(), start_html('Upload Test'), h1('Upload Test'), start_multipart_form(), "Enter how many files to upload: ", textfield("filecount"), br(); for my $i (1..param('filecount')) { print "File $i: ", filefield(-name => "file$i"), br(); } print submit(); for my $file (sort grep /file/, param()) { print p(); my $handle = upload($file); open (IMAGE, ">$handle") || die "Couldn't open $handle: $!"; # I realize that the above line needs to have a dir with write per +missions, etc. my $buffer; while (read($handle, $buffer, 10240)) { print IMAGE $buffer; } unless (defined($handle)) { if ($file =~ /(\d+)/) { print h3("File request $1 did not return a handle\n"); } next; } print p(), h3("Uploaded $handle"), br(), "<pre>"; print encode_entities($_) while <$handle>; print "</pre>"; } close(IMAGE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: Uploads (again!)
by tilly (Archbishop) on Jan 16, 2001 at 07:00 UTC | |
by Stamp_Guy (Monk) on Jan 16, 2001 at 10:20 UTC | |
by a (Friar) on Jan 16, 2001 at 10:57 UTC |