Skip to main content
Inspiring
May 7, 2008
Answered

Zip file uploaded by CF can't be unzipped by CF or Java

  • May 7, 2008
  • 2 replies
  • 1208 views
I'm having a WTF moment right now trying to track down this problem. I am creating a monitoring tool for our merge email system. What I would like to do is submit a job zip file through our upload form, in which case I just need to upload a zip file with cfhttp to the action page.

What I'm running into is a problem unzipping the file when it is on the server. However if I go to the server the received file opens fine with WinRAR or Windows Explorer. If I manually go to our form and upload the exact same file it works fine. Really odd. I can only find very basic information about uploading files with cfhttp and tried all of the attributes that seemed logical.

Attached is very basic example of the problem. It may end up being a bug in CF or something.

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.
================
    This topic has been closed for replies.
    Correct answer -__cfSearching__-
    danielmroberts,

    I tested it and received the same error. Using GetHttpRequestData() I did notice the size of the received file is usually 2b bigger than original. Though I do not know if that matters at all.

    The strange thing is if you add another parameter after the zip file (an empty text file or a form field), it suddenly works.

    <cfhttp url=" http://#cgi.http_host##cgi.script_name#?upload" method="post" result="jobSubmitResult">
    <cfhttpparam name="zipfile" type="file" file="#path#temp.zip" />
    <cfhttpparam name="placeholder" type="FormField" value="Empty Field">
    </cfhttp>

    2 replies

    Inspiring
    May 9, 2008
    Thank you!!!!!!! You are the man. I added a field as you described and it works. I'll submit this as a bug.
    Inspiring
    May 9, 2008
    You are welcome. Glad I could help :)
    Inspiring
    May 9, 2008
    > Using GetHttpRequestData() I did notice the size of the received file is usually 2b bigger than original.
    Whoops. That should be "using GetHttpRequestData() _and_ cfdirectory , I did notice ..."
    Inspiring
    May 9, 2008
    Here is a cleaner version of the demo code. This will go through all of the steps in the same code and shows where the problem occurs. If someone can run this and see if they run into the same error I would appreciate. If someone has a solution for this that would be great, otherwise I will be submitting a bug report and opt with a less preferred solution.

    ===
    -__cfSearching__-Correct answer
    Inspiring
    May 9, 2008
    danielmroberts,

    I tested it and received the same error. Using GetHttpRequestData() I did notice the size of the received file is usually 2b bigger than original. Though I do not know if that matters at all.

    The strange thing is if you add another parameter after the zip file (an empty text file or a form field), it suddenly works.

    <cfhttp url=" http://#cgi.http_host##cgi.script_name#?upload" method="post" result="jobSubmitResult">
    <cfhttpparam name="zipfile" type="file" file="#path#temp.zip" />
    <cfhttpparam name="placeholder" type="FormField" value="Empty Field">
    </cfhttp>