#!/usr/bin/perl -w # This program uses the CGI.pm library (see stein.cshl.org/WWW/software/CGI/) # to create a web form for uploading files to a local directory. The most # important function here is "print," which outputs html text. The library # contains functions that make this easier, such as strong(...) which # produces emphasized text. The interesting Perl code starts with line # marked with ******, which reads student username and ids from a file # and inserts them into a hash table. The directory from which this is # loaded is not shown, for obvious security reasons. # This program is "stateless" in that each time the link is clicked, it # needs to run from the beginning, meaning that it has to reload the # hash table. A better (though for this example overkill) approach is # to use a persistent background server (such as a sql database server), # which can provide this program with the information it needs on demand. use strict 'refs'; use lib '..'; use CGI qw(:standard); use CGI::Carp qw/fatalsToBrowser/; print header(); print start_html("Uploading an Assignment"); print "
", "Enter your one-word username: ", p, "Enter your Hofstra student id: ", p, "Enter the assignment designation: ", p, "Enter the location of your file: ", p, " | ", textfield('username'), p, textfield('sid'), p, textfield('assignment'), p, filefield('filename','',40), br, " |