I noticed some issues running the exampe code in OSX due to the slash 
direction. I have adjusted that and cleanup the code a bit. I also removed some 
extra attributes that I had added in an attempt to get this working, but isn't 
actually included in the CF docs as being necessary.

===

<!--- get base directory, includes system specific slash at end --->
<cfset path = getDirectoryFromPath(getCurrentTemplatePath()) />

<cfif not structKeyExists(url,"upload")>
        <!--- create zip file --->
                <cffile action="write" file="#path#temp.txt" output="test" />
                <cfzip action="zip" file="#path#temp.zip" 
source="#path#temp.txt">
                
        <!--- try to unzip file --->
                <cfset error1 = false />
                <cftry>
                        <cfzip action="unzip" file="#path#temp.zip" 
destination="#path#" />
                        <cfcatch type="application">
                                <cfset error1 = true />
                        </cfcatch>
                </cftry>

        <!--- upload file to CF page that will attempt to unzip file (see 
<cfelse> below) --->
                <cfhttp url="http://#cgi.http_host##cgi.script_name#?upload"; 
method="post" result="jobSubmitResult">
                        <cfhttpparam name="zipfile" type="file" 
file="#path#temp.zip" />
                </cfhttp>
                
                <cfset error2 = trim(jobSubmitResult.filecontent) is not 
"successful unzip" />
                
        <!--- output results of test --->
                <cfoutput>
                        <p>
                                Unzip of non-uploaded file succeeded?
                                #!error1#
                        </p>
                        <p>
                                Unzip of uploaded file succeeded?
                                #!error2#
                        </p>
                        <hr>
                        <cfif error2>
                                <div>
                                        #jobSubmitResult.filecontent#
                                </div>
                        </cfif>
                        
                        <!--- output code at the end to verify changes during 
testing --->
                                <cffile action="read" 
file="#getCurrentTemplatePath()#" variable="thisFile" />
                                <hr>
                                <pre>#htmlEditFormat(thisFile)#</pre>
                </cfoutput>
<cfelse>

        <!--- save uploaded file to current folder, with different name --->
                <cffile action="upload" destination="#path#temp_uploaded.zip" 
filefield="zipfile" nameconflict="makeunique" />
                
        <!--- attempt to unzip file --->
                <cfset error = false />
                <cftry>
                        <cfzip action="unzip" file="#path#temp_uploaded.zip" 
destination="#path#" />
                        <cfcatch type="application">
                                <cfdump var="#cfcatch#" />
                                <cfset error = true />
                        </cfcatch>
                </cftry>
                
                <cfif not error>
                        successful unzip
                </cfif>
</cfif> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304936
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to