close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Renaming Filenames with 2 extensions

Thread began 6/29/2010 12:48 pm by deafboyz_audio386924 | Last modified 7/06/2010 4:08 pm by deafboyz_audio386924 | 1006 views | 5 replies |


Renaming Filenames with 2 extensions

I have a need to upload 2 copies of a image.... one 100 X 75 (small) and one 600 X 400 somethin (large) with 2 inner extensions to differentiate

The upload works fine.... What I want to do is name one " black_lab.small.jpg " and then name the other one " black_lab.large.jpg "

I can do this fine up until I encounter that same filename a 2nd time. WHen the script renames the duplicate filename with a _1 via "[NewFileName]_[Increment]"
the name comes out as " black_lab.small_1.jpg

I have tried the following


I have even tried putting it like this:
'FileName' => "[FileName].small",
'FileName' => "[FileName]".".small",

plus a few others....

I have tried multiple ways and they all some out with the _[increment] on the outside, not the inside...

So how Can I get the filenames to be

example_3.small.jpg and not example.small_1.jpg

Thanks ahead for your help....

Sign in to reply to this post

Jimmy Wu

Unfortunately, this isn't something that you'll be able to do using the upload. The [NewFileName] portion of the renaming uses the FileName that you set up like this [FileName].small or [FileName].large and adds the increment to it. It would require some custom modification of the code to get the renaming to work that way, so it is not supported.

Sign in to reply to this post


ok... that is not what i was hoping for but what can i say.... thats coding right?

I understand that this is not something that is supported out of the box with DFP2.... I tried modifing the other end to make it so that I would not have to use the .small and .large in filenames..... lets just say that its not feasible.... talkin about MAJOR mod...

So I am willing to do the custom mods on helper.php and the upload form to make it work... at least i only have 2 documents to work with compared to 150.

I have decent knowledge in PHP and am willing to take on this project, its a necessity..... Care to point me in the right direction with a general idea? I can handle it with a push in the right direction

Sign in to reply to this post


ok i got half way there.....


$newFilePath = preg_replace( $fileExtensionRegExp, $uniqueFileNamePart, $imageFilePath).'.small.jpg';
$endExtension = 'small.jpg';

I added the .small into the part at the end of helperphp.php where it names the file.... And it Works!!! almost.... I need a way to defferentiate which ones get a .large and which ones get a .small according to the final destination folder.....

I tried going off the value of $val['UploadFolder'] so that it looked like this....


if ($val['UploadFolder'] == 'videos/uploads/'){
$newFilePath = preg_replace( $fileExtensionRegExp, $uniqueFileNamePart, $imageFilePath).'.jpg';
$endExtension = 'jpg';

elseif ($val['UploadFolder'] == 'videos/uploads/thumbs/'){
$newFilePath = preg_replace( $fileExtensionRegExp, $uniqueFileNamePart, $imageFilePath).'.small.jpg';
$endExtension = 'small.jpg';
$imageQuality = intval($imageOptions[1]);

if($imageQuality > 100){
$imageQuality = 100;
if($imageQuality < 0 ){
$imageQuality = 0;

But that resulted in no file at all being uplaoded..... which i dont get b/c the value of $val['UploadFolder'] is 'videos/uploads/thumbs/'... so one of em should execute at least...

Need a lil help on this, even just an idea?

Sign in to reply to this post


maybe you want to consider just "overwriting" the file....
if the file already exists.

Sign in to reply to this post


b/c cameras use common naming conventions... if someone uploads a diff pic with the same name I need to rename the new one so that both can keep their respective images.

I think i am going another route with this.... i got halfway there but could not figure the rest out...

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...