I have nearly completed my first 'real' CGI script (yes I'm a Perl
newbi) which uploads a .zip file to a remote directory from a web form created
by my CGI script.
I'm running across a problem with capitalized letters turning up in
submitted script filenames or pathways. Consequently, selecting a file via my
form's Browse button doesn't work because the pathway the button returns always
has a capital letter in it. Something like this: "E:\temp\testfile.ZIP". If I
press submit it actually does upload the file, but for some reason those files
always have a file size of 0, which I then delete...
Things I've tried:
* If I make all uppercase letters lowercase by manually changing them
to their lowercase equivalent in the upload field, it work's perfectly, and the
file has the correct file size.
* Using the lc() function to make the submitted filename and pathway
string lowercase does make them lowercase but I still get files of zero
size.
* I tried changing where the temp file is stored by using adding this
line:
$TempFile::TMPDIRECTORY='/WWW_ROOT';
That doesn't fix anything.
* I've tried using this line:
$tmpfile = tmpFileName($query->param('$fullfile'));
to find out where the temporary file is getting stored but that doesn't
work either. When it dies, my $tmpfile string doesn't print any info.
* I've looked at numerous message boards but to no avail...
Has anyone encountered this problem before? Is there something wrong with
my script?
I'm using:
* Windows NT 4.0 with SP6
* Perl (ActiveState for Win32)
* ISP's Server? (I dunno; I'm new at all this-- Perl Diver CGI shows that my server software is Zeus/3.3 whatever that is)
* Perl (ActiveState for Win32)
* ISP's Server? (I dunno; I'm new at all this-- Perl Diver CGI shows that my server software is Zeus/3.3 whatever that is)
## snip of my script ##
sub save_file {
$description = param('description');
$instructions = param('instructions');
$name = param('name');
$email = param('email');
$file = param('filename');
$file=lc($file);
$fullfile = $file;
$file=~s/^.*(\\|\/)//; # STRIP PATHWAY OFF!
########################################
## BEGIN UPLOAD AND RUN SOME TESTS
########################################
##
fileext_test(); ###### TESTS FOR CORRECT EXTENTION
filename_test(); ##### TESTS FOR DUPLICATE NAME ON SERVER
$description = param('description');
$instructions = param('instructions');
$name = param('name');
$email = param('email');
$file = param('filename');
$file=lc($file);
$fullfile = $file;
$file=~s/^.*(\\|\/)//; # STRIP PATHWAY OFF!
########################################
## BEGIN UPLOAD AND RUN SOME TESTS
########################################
##
fileext_test(); ###### TESTS FOR CORRECT EXTENTION
filename_test(); ##### TESTS FOR DUPLICATE NAME ON SERVER
open (SAVEFILE, ">$savedir$file") ||
dienice("Can't open filehandle: $!\n");
while (read($fullfile, $buffer, 1024)) {
print SAVEFILE $buffer;
}
$tmpfile = tmpFileName($query->param('$fullfile')); ### THIS TESTS THE LOCATION OF THE THE TEMP FILE CREATED DURING THE UPLOAD.
close(SAVEFILE) || dienice ("Can't close filehandle: $!\n");
while (read($fullfile, $buffer, 1024)) {
print SAVEFILE $buffer;
}
$tmpfile = tmpFileName($query->param('$fullfile')); ### THIS TESTS THE LOCATION OF THE THE TEMP FILE CREATED DURING THE UPLOAD.
close(SAVEFILE) || dienice ("Can't close filehandle: $!\n");
filesize_test(); ###### TESTS FOR VALID
FILESIZE
nodata(); ##### TESTS FILE FOR DATA
########################################
########## END UPLOAD AND TESTS ########
########################################
nodata(); ##### TESTS FILE FOR DATA
########################################
########## END UPLOAD AND TESTS ########
########################################
## end snip ##
Thanks for any help!
- - - - - - - - - -
Jared Hess ([EMAIL PROTECTED])
Technical Writer / Webmaster
Wilcox Associates, Inc. (www.wilcoxassoc.com)
Jared Hess ([EMAIL PROTECTED])
Technical Writer / Webmaster
Wilcox Associates, Inc. (www.wilcoxassoc.com)
