#!/usr/bin/perl
use strict 'refs';
use lib '..';
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
# use CGI;

print header();
print start_html("Testing file upload...");
print h1("Testing file upload...");

print start_multipart_form(),
  "Choose a file:",
  filefield('input_file','',45),
  br,
  submit('submit','Send it in!'),
  endform;

my $dirname = "/users/staff/math/sbloch/html/class/160/psp/unsafe/tmp/";
if (my $file = param('input_file')) {
  my $mimetype = uploadInfo($file)->{'Content-Type'} || '';
  print "Here's your file of type $mimetype:\n";
  if (-T $file) {
    while (<$file>) {
      print;
      }
    print "End of file!\n";
    close ($file);
    }
  else {
    print "Sorry! you didn't upload a text file.\n";
  }
}
else {
  print "Unable to get file handle.\n";
  }
print "Wasn't that fun?\n";
exit (0);



# $cgi->set_directory
("/users/staff/math/sbloch/html/class/160/psp/unsafe/tmp") || die "Directory doesn't exist!\n";
# print "Set directory successfully!\n";
# $cgi->set_file_type ("handle");
# %data - $cgi->parse_form_data ();
# $user - $data{'username'};
# $filename = $data{'input'};
