| View previous topic :: View next topic |
| Author |
Message |
mtspecial
Joined: 08 Mar 2007 Posts: 14
|
Posted: Mar 12, 2007 4:09 pm Post subject: Upload with no extension |
|
|
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? |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 1107 Location: Undisclosed location
|
Posted: Mar 13, 2007 7:19 am Post subject: |
|
|
This is a bug. Next version will include this fix. Thank you!
Here goes quick fix: in upload.cgi replace
| Code: | | $filename=~ /(.+)\.(.+)/; |
with
| Code: | | $filename=~ /(.+)\.?(.+)/; |
|
|
| Back to top |
|
 |
mtspecial
Joined: 08 Mar 2007 Posts: 14
|
Posted: Mar 13, 2007 12:15 pm Post subject: |
|
|
This change causes the script to place a "." before the last character in the file name.
Upload "filename" results in "filenam.e" |
|
| Back to top |
|
 |
mtspecial
Joined: 08 Mar 2007 Posts: 14
|
Posted: Mar 13, 2007 12:25 pm Post subject: |
|
|
I'm finding that it does this regardless if there is an extension or not.
upload "file.jpg" results in "file.jp.g" |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 1107 Location: Undisclosed location
|
Posted: Mar 13, 2007 1:29 pm Post subject: |
|
|
Oh, sorry. Haven't tested it well. Files without extension are pretty rare.
Here goes correct code for that string:
| Code: |
$filename=~ /(.+)\.(.+)/;
my ($fn,$ext) = ($1,$2);
$fn=$filename unless $filename=~/\./;
|
also in upload.cgi replace 5 lines after "my $i;" to
| Code: |
$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;
|
|
|
| Back to top |
|
 |
mtspecial
Joined: 08 Mar 2007 Posts: 14
|
Posted: Mar 14, 2007 8:08 pm Post subject: |
|
|
Your newest code produces a different result...
upload "filename" results in "filename.filename" |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 1107 Location: Undisclosed location
|
Posted: Mar 15, 2007 7:52 am Post subject: |
|
|
| Sent you fixed upload.cgi by email |
|
| Back to top |
|
 |
rodrigomf
Joined: 14 May 2008 Posts: 2
|
Posted: Jul 01, 2008 8:42 pm Post subject: 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! |
|
| Back to top |
|
 |
PilgrimX182

Joined: 22 Mar 2006 Posts: 1107 Location: Undisclosed location
|
Posted: Jul 02, 2008 6:34 am Post subject: |
|
|
| Latest XUpload Pro support files without extension. |
|
| Back to top |
|
 |
|