XUpload - removing double extensions

Message
Author
ibiz
Posts: 6
Joined: Sep 16, 2007 3:14 am

removing double extensions

#1 Postby ibiz » Sep 24, 2007 5:30 pm

Many of our clients inadvertantly upload files with double extensions. It seems they have file extensions hidden on their computer so when they add an extension, they are actually adding two.

I noticed that Xupload seems to remove the 2nd extension, but not the "." before it. This is what results:

Orig. file: 3800.jpg.jpg

Uploads successfully as: 3800..jpg
(two dots)

Is there a way to have the script automatically remove the full double extension, including the second "." (e.g., should be 3800.jpg)

Thank you.

Jim

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

#2 Postby PilgrimX182 » Sep 25, 2007 6:54 am

In upload.cgi find this line:

Code: Select all

my ($fn,$ext) = $filename=~/^(.+)\.(.+)$/;
and add this code below

Code: Select all

$fn=~s/\.\./\./g;
this should replace double dot with single.

ibiz
Posts: 6
Joined: Sep 16, 2007 3:14 am

#3 Postby ibiz » Sep 25, 2007 4:46 pm

I added the line you suggested and for some reason I am still getting the double dot:

Original File: 0000.jpg.jpg

and it was uploaded as: 0000..jpg

This is what my script looks like:

my ($fn,$ext) = $filename=~/^(.+)\.(.+)$/;
$fn=~s/\.\./\./g;
$fn=$filename unless $filename=~/\./;


Thanks again for your help.

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

#4 Postby PilgrimX182 » Sep 26, 2007 6:48 am

Oh, then try this:

Code: Select all

$fn=~s/\.//g;