in reply to Re: Re: Changing file names as they are uploaded
in thread Changing file names as they are uploaded
It will exclude the extension from the substitution.my $rindex = rindex($imagename,'.'); $rindex = length($imagename) if $rindex == -1; substr($imagename,0,$rindex) =~ s/\W/_/g;
Update: Fixed bug for filenames w/o extensions that end in a nonword char.
Update2: Thought I'd golf this one a bit:
works correctly for $files such as "me~swimming.jpg", "J.R,ewing.jpg" and "abc;;;"substr($file,0,rindex($file,'.')%length"a$file") =~ s/\W/_/g;
-Blake
|
|---|