1. <cfcomponent name="fileFunctions" displayname="File Functions" hint="I handle file functions for the site" output="false">
  2. <!---
  3. ++++++++++++++++++++++++++++
  4. +    UPLOAD FILE
  5. ++++++++++++++++++++++++++++
  6. --->
  7.     <cffunction name="uploadFile" access="public" output="false" returntype="string" hint="returns name of file uploaded">
  8.         <cfargument name="destination" type="string" required="true" hint="This is the destionation where the file is to be uploaded" />
  9.         <cfargument name="fileField" type="variableName" required="true" hint="This is the name of the form field that contains the file" />
  10.         <cfargument name="acceptType" type="string" required="false" default="" hint="Valid File Types" />
  11.         <cfargument name="nameConflict" type="string" required="false" default="MakeUnique" hint="nameConflict value for cffile" />
  12.         <!--- upload file --->
  13.         <cffile action="upload" destination="#arguments.destination#" filefield="#arguments.fileField#" accept="#arguments.acceptType#" nameconflict="#arguments.nameConflict#" />
  14.         <cfreturn file.serverFile />
  15.     </cffunction>
  16. <!---
  17. ++++++++++++++++++++++++++++
  18. +    RENAME FILE
  19. ++++++++++++++++++++++++++++
  20. --->
  21.     <cffunction name="renameFile" access="public" output="false" returntype="void" hint="renames an exisiting file on the site">
  22.         <cfargument name="source" type="string" required="true" hint="this is the name of the file to be renamed" />
  23.         <cfargument name="destination" type="string" required="true" hint="this is the new name the file" />
  24.         <cffile action="rename" source="#arguments.source#" destination="#arguments.destination#" />
  25.         
  26.     </cffunction>
  27. <!---
  28. ++++++++++++++++++++++++++++
  29. +    REMOVE FILE
  30. ++++++++++++++++++++++++++++
  31. --->
  32.     <cffunction name="removeFile" access="public" output="false" returntype="void" hint="removes an exisiting file from the site">
  33.         <cfargument name="fileName" type="string" required="true" hint="this is the name of the file to be removed" />
  34.         <cfargument name="filePath" type="string" required="true" hint="this is the path of the file to be removed" />
  35.             
  36.         <cfscript>
  37.             var fullFilePath = arguments.filePath & arguments.fileName;
  38.         </cfscript>
  39.         <!--- if the files exist delete them --->
  40.         <cfif fileExists(fullFilePath)>
  41.             <cffile action="delete" file="#fullFilePath#" />    
  42.         </cfif>
  43.     </cffunction>
  44. </cfcomponent>