March 1996
Intermediate to advanced
450 pages
10h
English
CGI Lite is a Perl 5 library that will decode both URL-encoded and multipart form data produced by the file upload feature present in Netscape 2.0. This module does not have all of the features of the CGI::* modules, but is lightweight and slightly easier to use. Here is a simple example that outputs all the form data:
#!/usr/local/bin/perl5 use CGI_Lite; $cgi = new CGI_Lite (); $cgi->parse_form_data (); print “Content-type: text/plain", “\n\n"; $cgi->print_form_data (); exit (0);
The parse_form_data method parses the form data and stores it in an internal associative array, which can be printed out by calling the print_form_data method. Or, you can place the form data in a variable of your choice:
#!/usr/local/bin/perl5
use CGI_Lite;
$cgi = new CGI_Lite ();
%data = $cgi->parse_form_data ();
print “Content-type: text/plain", “\n\n";
foreach $key (keys %data) {
print $key, “ = “, $data{$key}, “\n";
}
exit (0);
The file upload feature of Netscape 2.0 allows you to do just that: send files as part of a form through the network. Here is how to create a multipart form:
<HTML> <HEAD><TITLE>CGI Lite Test</TITLE></HEAD> <BODY> <H1>CGI Lite Test</H1> <HR> <FORM ACTION="/cgi-bin/upload.pl” ENCTYPE="multipart/form-data” METHOD="POST"> What is your name? <INPUT TYPE="text” NAME="username"> <P> Select a <B>TEXT</B> file to send: <INPUT TYPE="file” NAME="input_file"> <P> <INPUT TYPE="submit” VALUE="Send the Multipart Form"> <INPUT TYPE="reset” VALUE="Clear ...
Read now
Unlock full access