#!/usr/local/bin/perl
# File upload mod
use CGI;
$query = new CGI;
### Gets the input from the web page form and converts
read(STDIN, $strIN, $ENV{"CONTENT_LENGTH"});
chomp($strIN);
print "
";
($set1, $set2, $set3) = split(/\&/,$strIN);
($field1name,$field1value) = split(/\=/,$set1);
($field2name,$field2value) = split(/\=/,$set2);
($field3name,$field3value) = split(/\=/,$set3);
print "Content-Type: text/html;\n\n";
print qq|
Did it work? $field2name $field4name$set1, $set2, $set3 $Filename
|; print $field1name; print $field1value; print $set1; print $set2; print qq|;
|;
# File upload parameters
# --------------------------------------------------------
#
# File uploads -- if you want to be able to upload files, set this to 1
$db_upload = 1;
# Full path to directory for uploaded files -- NOT A URL!!!! No trailing slash please.
$SAVE_DIRECTORY = "../../pntemp";
# Full URL to directory for uploaded files. No trailing slash please.
$SAVE_DIRECTORY_URL = "http://www.mydomain.com/pntemp";
# Defines the number of bytes that can be uploaded. Files that exceed
# this limit will not be saved on the server. Set this to zero in order to
# disable size checking.
$MAXIMUM_UPLOAD = 10000;
# List of allowable file extensions. If the file does not have one of the extensions
# listed, it will not be saved to the server. The format for the setting is
# \.[extension]$ If you want to allow more than one extension, separate the options by
# a | character.
$ALLOWED_EXT = '\.pnt$|\.txt$';
my ($filekey,$filename,$newfilename,$extlength,$filehandle,$totalbytes,$buffer,$bytes,@extensions,@ext);
$| = 1;
#$filekey = $query->param("Filename");
$filekey = "C:\CETemp\dos.pnt";
#$filekey = $field1value;
$newfilename = bob;
opendir (GRAPHIC, "$SAVE_DIRECTORY") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
$file_test = bob;
foreach $file (@files) {
if ($file =~ /^$file_test/) {
unlink ("$SAVE_DIRECTORY/$file");
}
}
if (!open(OUTFILE, ">$SAVE_DIRECTORY\/$filename")) {
return "There was an error opening '$SAVE_DIRECTORY\/$filename' for Writing.\n";
}
binmode(OUTFILE); # This is needed to work on Windows/NT platforms.
while ($bytes = read($filekey,$buffer,1024)) {
$totalbytes += $bytes;
print OUTFILE $buffer;
}
close($filekey);
close(OUTFILE);
chmod (0666, "$SAVE_DIRECTORY\/$filename");
return "ok";