ColdFusion Zip and Download Directory code example

Example: ColdFusion Zip and Download Directory

<cfset fileName = createUUID() />
<cfif DirectoryExists("D:/tempDir")>
    <cfdirectory action = "list" directory = "D:/tempDir" name = "getAllFiles"  type="file" />
        <cfzip action="zip" file="D:/zipfilefolder/#fileName#.zip" overwrite="yes" >
            <cfloop query="getAllFiles">    
                <cfzipparam  source="D:/tempDir/#getAllFiles.name#">
            </cfloop>
        </cfzip>
</cfif>
<cfcontent deleteFile="true" file="D:/zipfilefolder/#fileName#.zip" type="application/x-zip-compressed" >
<cfheader name = "Content-disposition" value = 'attachment; filename="D:/zipfilefolder/#fileName#.zip"'>