7 print start_html("File Upload Example");
8 print strong("Version "),$CGI::VERSION,p;
10 print h1("File Upload Example"),
11 'This example demonstrates how to prompt the remote user to
12 select a remote file for uploading. ',
13 strong("This feature only works with Netscape 2.0 browsers."),
15 'Select the ',cite('browser'),' button to choose a text file
16 to upload. When you press the submit button, this script
17 will count the number of lines, words, and characters in
20 @types = ('count lines','count words','count characters');
22 # Start a multipart form.
23 print start_multipart_form(),
24 "Enter the file to process:",
25 filefield('filename','',45),
27 checkbox_group('count',\@types,\@types),
29 reset,submit('submit','Process File'),
32 # Process the form if there is a file name entered
33 if ($file = param('filename')) {
34 $tmpfile=tmpFileName($file);
38 my($lines,$words,$characters,@words) = (0,0,0,0);
41 $words += @words=split(/\s+/);
42 $characters += length($_);
45 grep($stats{$_}++,param('count'));
47 print strong("Lines: "),$lines,br if $stats{'count lines'};
48 print strong("Words: "),$words,br if $stats{'count words'};
49 print strong("Characters: "),$characters,br if $stats{'count characters'};
51 print strong("No statistics selected.");
56 a({href=>"../cgi_docs.html"},"CGI documentation"),
59 a({href=>'/~lstein'},"Lincoln D. Stein")),
61 'Last modified July 17, 1996',