
speicher
Deleted
Jan 27, 2000, 10:03 PM
Post #1 of 2
(4414 views)
|
How to do a fileupload
|
Can't Post
|
|
I'm trying to do a fileupload using the CGI.pm in Perl. I'm using Perl V5 on the OS/390. I keep getting a "malformed multipart POST" error. Below is a snippet of my code to show I'm using a multipart form. It's when I select the Process file button, that the above error occurs on the server. Any help is greatly appreciated! use lib '/usr/local/lib/perl5'; use CGI qw(:all); print "Content-Type: text/html\n\n"; print start_html("File Upload Example"); # Start a multipart form. print start_multipart_form(), "Enter the file to process:", filefield('filename','',45), br, checkbox_group('count',\@types,\@types), p, reset,submit('submit','Process File'), endform; # Process the form if there is a file name entered if ($file = param('filename')) { $tmpfile=tmpFileName($file); $mimetype = uploadInfo($file)->{'Content-Type'} | | ''; print hr(), h2($file), h3($tmpfile), h4("MIME Type:",em($mimetype)); my($lines,$words,$characters,@words) = (0,0,0,0); while (<$file> ) { $lines++; $words += @words=split(/\s+/); $characters += length($_); } close $file; grep($stats{$_}++,param('count')); if (%stats) { print strong("Lines: "),$lines,br if $stats{'count lines'}; print strong("Words: "),$words,br if $stats{'count words'}; print strong("Characters: "),$characters,br if $stats{'count characters'}; } else { print strong("No statistics selected."); } }
|