Can someone point me in the right direction of converting the following
script to use an html template? 
 
#!/usr/bin/perl -w
# perlUpload.cgi by John Pretti
# Comments/Questions john[at]web-connected.com
# Last modified 05/03/04
 
# Load needed Perl modules
use strict;
use diagnostics;
use CGI; # Make HTML easy to deal with
use CGI::Carp 'fatalsToBrowser'; # Report errors to browser
$CGI::POST_MAX=1024 * 100;  # max 100K posts
 
# Allowed file types
my @good_extensions = ('doc', 'DOC', 'Doc', 'rtf', 'RTF', 'Rtf', 'pdf',
'PDF', 'Pdf');
 
# Create new CGI object
my $q = new CGI;
 
if ( $q->param() ) {
 
        # Read filehandle from param and set to binary mode
        my $filehandle = $q->param('file');
        binmode($filehandle);
 
        # Strip off Windoze crap compliments of JHARRISS
        $_=$filehandle;
        s/.*\\//;
        my $filename=$_;
 
        # Check to see if filetype is allowed compliments of JHARRISS
        $_=$filename;
        s/.*\.//;
        my $extension=$_;
        my $ingood_extensions=0;
        foreach (@good_extensions) {
                if ($_ eq $extension) {
                $ingood_extensions=1;
                }
        }
        if ($ingood_extensions == 1) {
 
 
        # Open file for output
        open(OUT,">/www/web/htdocs/merlin/upload/$filename") || die $!;
        binmode(OUT);
 
:92
              $q->start_multipart_form,
              $q->filefield('file'),
              $q->br,
              $q->submit('Upload'),
              $q->end_form,
              $q->end_html;
              exit (1);
              }
 
        } else {
               if ($q->cgi_error()) {
                        print   $q->header,
                                $q->start_html('Merlin Control Center'),
                                $q->p("File upload has failed. Files must be
under 4MB in size. Please try again"),
                                $q->start_multipart_form,
                                $q->filefield('file'),
                                $q->br,
                                $q->submit('Upload'),
                                $q->end_form,
                                $q->end_html;
              } else {
                        print   $q->header,
                                $q->start_html('Merlin Control Center'),
                                $q->img({-src=>'/merlin/images/usda.gif'}),
                                $q->br,
                                $q->start_multipart_form,
                                $q->filefield('file'),
                                $q->br,
                                $q->submit('Upload'),
                                $q->end_form,
                                $q->end_html;
              }
 
        }
 
While the above script, works perfectly, I would like to make it look a lot
more attractive and I am having some troubles understanding how to get my
html code to play nicely with CGI.pm. Thanks in advance.
 
Cheers,
John Pretti
 
 

Reply via email to