Dealing with Filename Conflicts

XUpload related questions

Moderator: admin

Posts: 2
Joined: Aug 18, 2007 4:51 am

Dealing with Filename Conflicts

#1 Postby HolmesSPH » Aug 18, 2007 4:55 am

Let me just say that thus far this product has been worth every dime!

It's a great alternative for me because I need to integrate some other perl functions into uploads after their done, and with PHP none of this is possible.

Anyways my problem is that if a file already exists with the current filename in the target directory then it just over writes it instead of creating a new unique filename for it.

I build an MP3 uploader a year ago and basically checked if it existed and if it did then I renamed the uploaded file to (1)somefile.mp3 and then tried again increasing the file name with a (2), then (3) till it hit a uniqe name..

Now I am sure there are MUCH easier ways but its not like we have millions of files ;)

What can be done to get files names to change dynamically if their is already a file existing in the that directory?

Posts: 4
Joined: Aug 12, 2007 8:10 pm

#2 Postby bbunlock » Aug 18, 2007 3:23 pm

hi just another user thats happy with the product and thought I might be able to help, so just to make sure I have this right, if you upload "somesong.mp3" you want the script to not overwrite the file already on the system called "somesong.mp3" instead you want it to create a new file called (for example) "somesong1.mp3"

the script is already setup to do just that, in fact my script has been doing that from day one, it checks the target folder for a file with that name and if it finds it then it renames the uploaded file to something1.mp3, im in the same boat as you with uploads as my script is used for uploading mp3's and other audio files to create ringtones from them.

if you check the config file "" look for the section

Code: Select all

 # Type of behavior when uploaded file already exist on disc. Available 3 modes: Rewrite/Rename/Warn
 copy_mode       => 'Rename',

see what yours is set to, from what your saying about it overwritng the file im guessing yours is set to "Rewrite" mine is set to "Rename" (as shown in the code above) which means it creates the file with the number appended to it, so somesong.mp3 would be somesong1.mp3 and of course the number goes up depending on how many versions of that song are on the system.

hope this helps


Posts: 2
Joined: Aug 18, 2007 4:51 am


#3 Postby HolmesSPH » Aug 18, 2007 4:20 pm

Awesome! Thanks, that did the trick!

Posts: 4
Joined: Aug 12, 2007 8:10 pm

#4 Postby bbunlock » Aug 18, 2007 11:00 pm

glad I could help

User avatar
Posts: 2181
Joined: Mar 22, 2006 1:39 pm
Location: UFO Lab

#5 Postby PilgrimX182 » Aug 20, 2007 6:06 am

Thank you! :D

Return to “XUpload”

Who is online

Users browsing this forum: No registered users and 0 guests