The code of this script is:
#!/usr/bin/perl# Copyright (c) 1996 Steven E. Brenner
# $Id: fup.cgi,v 1.2 1996/03/30 01:35:32 brenner Exp $
use CGI::Carp qw(fatalsToBrowser);
require "./cgi-lib.pl";
$ref_number = 12345;
#Delete old file
$delfile = "/home/easy/public_html/cvs/$ref_number.doc";
unlink $delfile;
# When writing files, several options can be set... here we just set one
# Limit upload size to avoid using too much memory
$cgi_lib'maxdata = 50000;
$cgi_lib'writefiles = "/home/easy/public_html/cvs";
# Start off by reading and parsing the data. Save the return value.
# We could also save the file's name and content type, but we don't
# do that in this example.
$ret = &ReadParse;
# A bit of error checking never hurt anyone
&CgiDie("Error in reading and parsing of CGI input") if!defined $ret;
&CgiDie("No data uploaded", "Please enter it in <a href='fup.html'>fup.html</a>.")
if!$ret;
# Munge the uploaded text so that it doesn't contain HTML elements
# This munging isn't complete -- lots of illegal characters are left as-is.
# However, it takes care of the most common culprits.
$in{'upfile'} =~ s/</</g;
$in{'upfile'} =~ s/>/>/g;
$uploadedfile = $in{'upfile'};
rename($uploadedfile, "/home/easy/public_html/cvs/"."$ref_number".".doc");
# Now produce the result: an HTML page...
#print &PrintHeader;
print &HtmlTop("File Upload Results");
print <<EOT;
<p>You've uploaded a file $uploadedfile. Your notes on the file were:<br>
<blockquote>$in{'note'}</blockquote><br>
EOT
print &HtmlBot;
Any help in this regard will be appreciated. This is one stumbling block I really must overcome. The other uploading scripts available on the web do not allow me to include other data, only the file.
Thanks.
[search.cpan.org...]
I think you'll have to allow the upload and delete the file afterward if it has an unallowable extension or rely on JavaScript to check the extension before you post.