ColdFusion Muse

Flash Upload and Zero Length Content

Mark Kruger October 26, 2006 9:50 AM Coldfusion Troubleshooting Comments (2)

We have an application that uses the directory and upload functions that are a part of flash (starting with version 8) to build a list of files and post them one by one to a Coldfusion handler. We took this process from one server, a Coldfusion 6.1 server on Windows 2003, to a new server, a Coldfusion 7.02 server on Windows 2003. Suddenly we noticed a host of new error messages. The errors all indicated that no form data had been posted by the uploader. We checked and files were still being uploaded. It was a mystery.

We beefed up the error handler to pass back the GetHttpRequestData() and the CGI scope in the body of the email it was sending. We also set up an email to send us the same data for healthy, successful requests. We found that the "no form content" requests were all set up with a zero length in the content-length header. We also found that hte "zero length" request and a successful healthy request came in pairs - one followed by the other. It didn't affect everyone either. I googled around and it appears that a certain version of Flash 8 actually sends 2 requests - a zero length request, followed by the actual POST request containing the file data. Once we were sure that the zero content length requests were an anomaly and not a real error we added this code to the top of our handler.

<cfif cgi.CONTENT_LENGTH IS "0">
    No file...
    <cfabort>
</cfif>
This saved our CFFILE operations from the necessity of throwing an error. My only question is, why did this behavior "suddenly" show up when we moved from CF 6.1 to CF 7.02? Perhaps one of my readers who is a flash guru can fill me in on this nuance to the upload behavior.

  • Share:

2 Comments


Leave this field empty

Write a comment

If you subscribe, any new posts to this thread will be sent to your email address.

  • David R's Gravatar
    Posted By
    David R | 10/26/06 11:55 AM
    When uploading a file, Flash 8 will first try to upload a 0-byte file, just to make sure the upload URL does not return 404, or the server does not exist. So it was probably doing the same thing on CF6.1, but perhaps it had less strict error checking, and was not logging the errors.
  • Mark Kruger's Gravatar
    Posted By
    Mark Kruger | 10/26/06 12:03 PM
    David,

    Well, I thought the same thing - but the error code is a duplicated between the 2 servers - so I'm at a loss why the error "suddenly" started happening. The zero byte flash thing is kind of bogus. I'm not sure what they were thinking there - wanting to avoid a 404... how nice... plus the added benefit of doubling requests to the server :)