Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: File Upload

Quote Reply
Re: File Upload In reply to
Anybody have a solution?

When an uploaded file is Added, it renames the file to the id number of the record. However, it destroys all files in the folder and renames the file something like ".gif" or ".jpg". We believe a contribution to the problem is found in the validate_upload subroutine. We commented out various lines to test.

What specifically is the $file = $1; line doing?

Also I don't quite understand
$extlength = length($filename) - index($filename,".");
The entire program fails when removing the "."

We are using Windows and maybe this contributes to some problem

File: db.cgi
sub validate_upload

if ($filekey =~ /([^\/\\]+)$/) {
$filename = $1;
$extlength = length($filename) - index($filename,".");
$filename = $newfilename . lc(substr($filename,-$extlength,$extlength));
unless ($filename =~ /$ALLOWED_EXT/) {
$ALLOWED_EXT =~ s/\\//g;
$ALLOWED_EXT =~ s/\$//g;
@ext = split (/\Q|\E/o,$ALLOWED_EXT);
$ALLOWED_EXT = join(" or ",@ext);
return "Only files with the following extension(s) are allowed: $ALLOWED_EXT";
}
}

------------------

Many thanks
John

Subject Author Views Date
Thread File Upload gatman 3341 Apr 20, 2001, 8:35 AM
Thread Re: File Upload
gatman 3198 Apr 23, 2001, 7:19 AM
Post Re: File Upload
Paul 3209 Apr 23, 2001, 7:36 AM
Thread Re: File Upload
Stealth 3209 Apr 23, 2001, 7:58 AM
Post Re: File Upload
gatman 3175 Apr 25, 2001, 4:53 AM