Assuming you are uploading from a form and the name of the file field is "file", the routine below will do it. You will need to rename the paths as necessary. This routine will:
1) Rename the file with incremental numbers (1, 2, 3, etc) 2) Ensure the file name uses only standard characters (so it can be used in URL strings if you want to link to the file) 3) Report back the final uploaded file name as the variable "upl_file" 4) Prevent users from uploading dangerous file types (.cfm, .com, .exe, etc.) Hope this helps. <cfsetting requesttimeout="3600"> <cfparam name="form.file" default=""> <!--- *********************** START OF FILE HANDLING *********************** ---> <cfif #form.file# is not ""> <cffile action="upload" filefield="file" destination="ROOT\YOUR_PATH_HERE" nameconflict="makeunique"> <cfset file_ext="#ListLast(serverfile,".")#"> <cfif file_ext is "exe" or file_ext is "com" or file_ext is "cfm" or file_ext is "cfml" or file_ext is "dll" or file_ext is "mdb" or file_ext is "vbs"> <p class="msg"><img src="../error.gif" border="0"><br />The file you uploaded uses the<br /> extension .<cfoutput>#file_ext#</cfoutput>.</p> <p class="msg"><strong>This file type is not allowed.<br /> The upload is aborted.</strong><br /> <br /> Please return and select an acceptable file type<br /> or zip the file before uploading.</p> <p class="center"><br /><cfoutput><form class="center"><input type="button" name="back" value="Back to <cfif reply eq 1>Reply to Message<cfelse>Post A New Message</cfif>" onClick="history.go(-1)"></form></cfoutput></p> </div> </body> </html> <cffile action="delete" file ROOT\YOUR_PATH_HERE\#serverfile#"> <cfabort> </cfif> <cfset upl_file="#serverfile#"> <cfset upl_descr="#clientfile#"> <!--- ***************** ensures file name will be a legal name having no special characters ************************** ---> <cfset upl_file_nme="#ListFirst(serverfile,".")#"> <cfset upl_file_ext="#ListLast(serverfile,".")#"> <cfset upl_file_nme="#ReplaceList(trim(upl_file_nme), " ,]'", ",,")#"> <cfset upl_file_nme="#REREPLACE("#upl_file_nme#","#chr(8226)#","","all")#"> <cfset upl_file_nme="#REReplace (upl_file_nme, "[##""%/\\*?<>|:$'&@,(){}~`^!+;=[]", "", "all")#"> <cfset upl_file_nme2="#upl_file_nme#"> <cfset new_file="#upl_file_nme#.#upl_file_ext#"> <cfif new_file is not "#serverfile#"> <!--- if the file name has changed ---> <cfdirectory action="list" directory = ROOT\YOUR_PATH_HERE\" name="checkfile" filter="#new_file#"> <!--- renames file until name is unique ---> <cfif checkfile.recordcount gt 0> <cfset unique=0> <cfset fcount=1> <cfloop condition="unique neq 1"> <cfset upl_file_nme2="#upl_file_nme##fcount#"> <cfdirectory action="list" directory = ROOT\YOUR_PATH_HERE\" name="checkfile" filter="#upl_file_nme2#.#upl_file_ext#"> <cfif checkfile.recordcount eq 0> <cfset unique=1> <cfbreak> <cfelse> <cfset fcount=#fcount#+1> </cfif> </cfloop> </cfif> <cfset upl_file="#upl_file_nme2#.#upl_file_ext#"> <cffile action="rename" source ROOT\YOUR_PATH_HERE\#serverfile#" destination ROOT\YOUR_PATH_HERE\#upl_file#"> <cfelse> <cfset upl_file="#serverfile#"> </cfif> <cfelse> <cfset upl_file=""> </cfif> <!--- ***************** end of file rename routine *************************** ---> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317653 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4