XUpload - Upload with no extension

Message
Author
mtspecial
Posts: 14
Joined: Mar 08, 2007 8:39 pm

Upload with no extension

#1 Postby mtspecial » Mar 12, 2007 4:09 pm

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?

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#2 Postby PilgrimX182 » Mar 13, 2007 7:19 am

This is a bug. Next version will include this fix. Thank you!
Here goes quick fix: in upload.cgi replace

Code: Select all

$filename=~ /(.+)\.(.+)/;
with

Code: Select all

$filename=~ /(.+)\.?(.+)/;

mtspecial
Posts: 14
Joined: Mar 08, 2007 8:39 pm

#3 Postby mtspecial » Mar 13, 2007 12:15 pm

This change causes the script to place a "." before the last character in the file name.

Upload "filename" results in "filenam.e"

mtspecial
Posts: 14
Joined: Mar 08, 2007 8:39 pm

#4 Postby mtspecial » Mar 13, 2007 12:25 pm

I'm finding that it does this regardless if there is an extension or not.

upload "file.jpg" results in "file.jp.g"

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#5 Postby PilgrimX182 » Mar 13, 2007 1:29 pm

Oh, sorry. Haven't tested it well. Files without extension are pretty rare.
Here goes correct code for that string:

Code: Select all

   $filename=~ /(.+)\.(.+)/;
   my ($fn,$ext) = ($1,$2);
   $fn=$filename unless $filename=~/\./;
also in upload.cgi replace 5 lines after "my $i;" to

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;

mtspecial
Posts: 14
Joined: Mar 08, 2007 8:39 pm

#6 Postby mtspecial » Mar 14, 2007 8:08 pm

Your newest code produces a different result...

upload "filename" results in "filename.filename"

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#7 Postby PilgrimX182 » Mar 15, 2007 7:52 am

Sent you fixed upload.cgi by email

rodrigomf
Posts: 3
Joined: May 14, 2008 6:59 pm

Can you post the solution?

#8 Postby rodrigomf » Jul 01, 2008 8:42 pm

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!

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#9 Postby PilgrimX182 » Jul 02, 2008 6:34 am

Latest XUpload Pro support files without extension.