Return to Snippet

Revision: 31356
at June 11, 2011 07:02 by landock


Updated Code
<cfset startDir = "C:\">
<cfset newDir = startDir & replace(Form.Listing, " ", "_", "All")>
<cfdirectory directory="#newDir#" action="CREATE" >
<cfset aResults = StructFindKey(#Form#, "FiletoUpload-0", "all")>
<!---<cffile action="upload"
destination="#newDir#"
nameConflict="overwrite"
fileField="Form.FiletoUpload-0">--->

<body>
    <cfoutput>
    <cfloop collection = #Form# item = "forms">
    <tr>
        <td>#StructFind(Form, forms)#</td>
    </tr>
    </cfloop>
        <p>Your directory #newDir# has been created</p>
        <p>Your file has been uploaded</p>
    </cfoutput>
    <cfdump var="#aResults#">
</body>
</html>
<cfif StructKeyExists(Form, "fieldnames")>
    <cfloop list=#form.fieldnames# index="i">
        <cfif FindNoCase("FiletoUpload-",i) AND Len(form[i])>
            <cffile action="upload"
            destination="#newDir#"
            nameConflict="overwrite"
            fileField="#i#"
            result="ThisFile">
	</cfif>
    </cfloop>
 </cfif>

Revision: 31355
at September 3, 2010 06:11 by landock


Initial Code
<cfset startDir = "C:\">
<cfset newDir = startDir & replace(Form.Listing, " ", "_", "All")>
<cfdirectory directory="#newDir#" action="CREATE" >
<cfset aResults = StructFindKey(#Form#, "FiletoUpload-0", "all")>
<!---<cffile action="upload"
destination="#newDir#"
nameConflict="overwrite"
fileField="Form.FiletoUpload-0">--->

<body>
	<cfoutput>
    <cfloop collection = #Form# item = "forms">
<tr>

<td>#StructFind(Form, forms)#</td></tr>
</cfloop>
        <p>Your directory #newDir# has been created</p>
        <p>Your file has been uploaded</p>
    </cfoutput>
    <cfdump var="#aResults#">

</body>
</html>

<cfif StructKeyExists(Form, "fieldnames")>
	<cfloop list=#form.fieldnames# index="i">
		<cfif FindNoCase("FiletoUpload-",i) AND Len(form[i])>
            <cffile action="upload"
            destination="#newDir#"
            nameConflict="overwrite"
            fileField="#i#"
            result="ThisFile">
		</cfif>
    </cfloop>
  </cfif>

Initial URL

                                

Initial Description

                                

Initial Title
upload files to directory

Initial Tags

                                

Initial Language
ColdFusion