#! /usr/bin/perl -w

##### Program description #######
#
# Title:     cgi4.pl
# Author(s): Mattias Ohlsson
# Description:
#   Small example of how to use the CGI module.
#
##################################

use strict;
use CGI;

# The error can be redirected to the browser
use CGI::Carp qw(fatalsToBrowser);

my $cgi = new CGI;

print $cgi->header,
    $cgi->start_html(-title=>'File Upload Example'),
    $cgi->h1('File Upload Example'),
    $cgi->start_multipart_form,
    "Give the path to a fasta file ",
    $cgi->p,
    $cgi->filefield(-name=>'upfile',-size=>50),
    $cgi->p,
    $cgi->submit,
    $cgi->end_form,
    $cgi->hr;

if ( $cgi->param() ) {
    my $filename = $cgi->upload('upfile');
    print "The fasta file $filename contains the following:",
    $cgi->br,$cgi->br;
    print "<pre>";
    while ( my $line = <$filename> ) {
        print "$line";
    }
    print "</pre>";
}
print $cgi->end_html();
