I found the code in my script that caused filenames (or pathways) uploaded
with uppercase letters or spaces in them to have a 0 file size.  The code I
used to have was:

### BEGIN CODE SNIP
$file = param('filename');
$file=lc($file);
$fullfile = $file;
$file=~s/^.*(\\|\/)//; # STRIP PATHWAY OFF!
fileext_test(); ###### TESTS FOR CORRECT EXTENTION
filename_test(); ##### TESTS FOR DUPLICATE NAME ON SERVER
binmode $fullfile;
open (SAVEFILE, ">$savedir$file") || dienice("Can't open filehandle: $!\n");
binmode SAVEFILE;
while (read($fullfile, $buffer, 1024)) {
print SAVEFILE $buffer;
}
### END CODE SNIP

...which would take my filename and pathway, make them lowercase (so that I
wouldn't have case differences when I tested for duplicate file names on the
server-- plus it just looked cleaner to have all lowercase filenames).
Unfortunately, the lc() function (which simply made my string lowercase)...

$file=lc($file);

...was causing the problem. I commented it out, re-ran my script and files
with capital letters and spaces uploaded fine. I don't know how this simple
line made uploaded files have 0 file size, but it did.

So now I have the same problem when I test for files with duplicate names on
the server. If I upload files with the names "testfile1.ZIP" and
"testfile1.zip", they're considered different file names. I don't want this.
I was all files uploaded to be lowercase (this was why I was using the lc()
function). Currently, I use this code to test for duplicate names:

### Begin Code Snip
sub filename_test{
        if (-e "$uploadpath/$file"){
        dienice ("File couldn't upload. The destination directory already
contains a file with the same name. Please rename your file, and use your
browser's Back button to resubmit your file.");
        exit;
        }
return 1;
}
### End Code Snip

How can I force submitted files to be lowercase and not run into the same 0
file size problem?
- - - - - - - - - -
Jared Hess ([EMAIL PROTECTED])
Technical Writer / Webmaster
Wilcox Associates, Inc. (www.wilcoxassoc.com)


_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to