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
XUpload - removing double extensions
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
In upload.cgi find this line:
and add this code below
this should replace double dot with single.
Code: Select all
my ($fn,$ext) = $filename=~/^(.+)\.(.+)$/;
Code: Select all
$fn=~s/\.\./\./g;
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.
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.
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Oh, then try this:
Code: Select all
$fn=~s/\.//g;