Simple Java to make sure that a directory exists before doing a cffile upload:
<cfset CreateObject("java", "java.io.File").init("C:\Inetpub\wwwroot\myNewDirectory\images").mkdirs() />
So, for example, you might do something like this:
<cfset CreateObject("java", java.io.File").init("c:\uploads\#dateformat(now(), 'yyyymmdd')#") />
You can just do the above before every upload. The first time it will create the directory, and every time after that it will just do nothing.
Thanks to cfgears for reminding me how to do this:
http://www.cfgears.com/index.cfm/2009/5/19/Tapping-in-to-ColdFusions-underlying-Java-capabilities
No comments:
Post a Comment