Posted By

landock on 09/03/10


Tagged


Versions (?)

upload files to directory


 / Published in: ColdFusion
 

  1. <cfset startDir = "C:\">
  2. <cfset newDir = startDir & replace(Form.Listing, " ", "_", "All")>
  3. <cfdirectory directory="#newDir#" action="CREATE" >
  4. <cfset aResults = StructFindKey(#Form#, "FiletoUpload-0", "all")>
  5. <!---<cffile action="upload"
  6. destination="#newDir#"
  7. nameConflict="overwrite"
  8. fileField="Form.FiletoUpload-0">--->
  9.  
  10. <cfoutput>
  11. <cfloop collection = #Form# item = "forms">
  12. <tr>
  13. <td>#StructFind(Form, forms)#</td>
  14. </tr>
  15. </cfloop>
  16. <p>Your directory #newDir# has been created</p>
  17. <p>Your file has been uploaded</p>
  18. </cfoutput>
  19. <cfdump var="#aResults#">
  20. </body>
  21. </html>
  22. <cfif StructKeyExists(Form, "fieldnames")>
  23. <cfloop list=#form.fieldnames# index="i">
  24. <cfif FindNoCase("FiletoUpload-",i) AND Len(form[i])>
  25. <cffile action="upload"
  26. destination="#newDir#"
  27. nameConflict="overwrite"
  28. fileField="#i#"
  29. result="ThisFile">
  30. </cfif>
  31. </cfloop>
  32. </cfif>

Report this snippet  

You need to login to post a comment.