Here is a one page test for the problem. I've tried this on different computers 
with Windows and OSX. Below is very basic, though messy, example of the 
problem. It may end up being a bug in CF or something, or I may just be missing 
something about uploading binary files...but I've tried all the option I could 
find with no success.

The code does the following
1. creates a text file
2. creates a zip file with the text file
3. tries to unzip the file to make sure it is fine 
4. uploads the file (processed by a <cfelse> block at the bottom)
5. tries to unzip the file uploaded

The error occurs in step 5. CF just can't unzip the uploaded file, but I can 
unzip it using other tools.

================ 

<cfif not structKeyExists(url,"upload")>
        <!--- create zip file then try to unzip --->
                <cffile action="write" file="#expandPath(".")#\temp.txt" 
output="test" />
                <cfzip action="zip" file="#expandPath(".")#\temp.zip" 
source="#expandPath(".")#\temp.txt">
                
                <cftry>
                        <cfdirectory action="create" 
directory="#expandPath(".")#\unzip1">
                        <cfdirectory action="create" 
directory="#expandPath(".")#\unzip2">
                        <cfcatch></cfcatch>
                </cftry>
                
                <!--- try unzip wihtout upload --->
                <cfset error = false>
                <cftry>
                        <cfzip action="unzip" file="#expandPath(".")#\temp.zip" 
destination="#expandPath(".")#\unzip1" />
                        <cfcatch type="application">
                                <cfset error = true>
                        </cfcatch>
                </cftry>
                
                <cfoutput>
                        <p>
                                Unzip of non-uploaded file succeeded? #(not 
error)#
                        </p>
                </cfoutput>
                
        <!--- upload file to CF page that will attempt to unzip file (see 
<cfelse> below) --->
                <cfset error = false>
                <cfhttp url="http://#cgi.http_host##cgi.script_name#?upload"; 
method="post" result="jobSubmitResult" multipart="true">
                        <cfhttpparam name="enctype" type="header" 
value="multipart/form-data">
                        <cfhttpparam name="zipfile" type="file" 
file="#expandPath(".")#\temp.zip" mimetype="application/zip" />
                </cfhttp>
                
                <cfif jobSubmitResult.filecontent does not contain "success">
                        <cfset error = true>
                </cfif>
                
                <cfoutput>
                <p>
                        Unzip of uploaded file succeeded? 
#(jobSubmitResult.filecontent contains "success")#
                </p>
                <hr>
                <cfif error>
                        <div>
                                #jobSubmitResult.filecontent#
                        </div>
                </cfif>
                </cfoutput>
<cfelse>
        
        
        <!--- upload processing --->
                <cfset error = false>
                <cftry>
                        <cfdirectory action="create" 
directory="#expandPath(".")#\uploaded">
                        <cfcatch type="application"></cfcatch>
                </cftry>
                
                <cffile action="upload" 
destination="#expandPath(".")#\uploaded" filefield="zipfile" 
nameconflict="overwrite">
        
        <!--- attempt to unzip --->
                <cftry>
                        <cfzip action="unzip" 
file="#expandPath(".")#\uploaded\#cffile.ServerFile#" 
destination="#expandPath(".")#\unzip2">
                        <cfcatch type="application">
                                <cfset error = true>
                                <cfdump var="#cfcatch#">
                        </cfcatch>
                </cftry>
        
                <cfif not error>
                        success
                </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:304874
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to