I am looking for a way to allow my users to upload files into a directory and prevent them from overwriting the file if the file name already exists.
For instance, UserA wants to upload a file name Project1. There is already a file named Project1 in there. I need to kick the user back out and let them know that they have to rename the file and try to upload the file again.
I can't use the MakeUnique - NameConflict attribute because we need to make the file name something that would make sense to the user who wishes to download the file. A name such as "Project1" would be meaningful. Each user has a unique username. Is there possibly a way to append the username to the filename if the filename alreadys exists in the directory? i.e. Project1_mike2277
We tried to use this code but no luck on ColdFusion Server MX. It works alright on 5.0 though.
<CFFILE
DESTINATION="F:\mySite\file_transfer\134
ACTION="UPLOAD"
NAMECONFLICT="skip"
FILEFIELD="FileName">
</cfif>
<CFIF #File.FileExisted# IS "YES">
Sorry, please go back and rename your file and try to upload it again.
<CFELSE>
Congratulations! Your file has been uploaded.
</CFIF>
Our error message though on MX is:
Element FILEEXISTED is undefined in FILE.
Any suggestions would be appreciated!
For instance, UserA wants to upload a file name Project1. There is already a file named Project1 in there. I need to kick the user back out and let them know that they have to rename the file and try to upload the file again.
I can't use the MakeUnique - NameConflict attribute because we need to make the file name something that would make sense to the user who wishes to download the file. A name such as "Project1" would be meaningful. Each user has a unique username. Is there possibly a way to append the username to the filename if the filename alreadys exists in the directory? i.e. Project1_mike2277
We tried to use this code but no luck on ColdFusion Server MX. It works alright on 5.0 though.
<CFFILE
DESTINATION="F:\mySite\file_transfer\134
ACTION="UPLOAD"
NAMECONFLICT="skip"
FILEFIELD="FileName">
</cfif>
<CFIF #File.FileExisted# IS "YES">
Sorry, please go back and rename your file and try to upload it again.
<CFELSE>
Congratulations! Your file has been uploaded.
</CFIF>
Our error message though on MX is:
Element FILEEXISTED is undefined in FILE.
Any suggestions would be appreciated!