Sometimes we have clients upload files with no extension (ie.. Font suitcae).
I've set the script to allow all extensions (.*), but if there is no extension, file_0. gets added to the beginning of the file.
exmaple:
user uploads a file called "Helvetica"
the file is uploaded and renamed to "file_0.Helvetica"
How do I stop this?
XUpload - Upload with no extension
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
This is a bug. Next version will include this fix. Thank you!
Here goes quick fix: in upload.cgi replace
with
Here goes quick fix: in upload.cgi replace
Code: Select all
$filename=~ /(.+)\.(.+)/;
Code: Select all
$filename=~ /(.+)\.?(.+)/;
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Oh, sorry. Haven't tested it well. Files without extension are pretty rare.
Here goes correct code for that string:
also in upload.cgi replace 5 lines after "my $i;" to
Here goes correct code for that string:
Code: Select all
$filename=~ /(.+)\.(.+)/;
my ($fn,$ext) = ($1,$2);
$fn=$filename unless $filename=~/\./;
Code: Select all
$ext=".$ext" if $ext;
$i++ while (-e "$c->{target_dir}/$fn$i$ext" && $c->{copy_mode} eq 'Rename');
$filename="$fn$i$ext";
push @file_status, "OK. renamed to:$filename" if $i;
&lmsg("MSG:File '$fn$ext' already exist!<br>New file saved as '$filename'.") if $i;
Can you post the solution?
Hi, I am having the same problem with some Mac users (I don't know why they use extensionless files).
Can you post the solution?
Thanx a lot!
Can you post the solution?
Thanx a lot!
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm