8 Replies Latest reply on Jul 8, 2008 12:17 AM by doug777

    Is there any way to view an HTTP POST request

    doug777 Level 1
      I am trying to upload a picture file using cffile. It works fine from a cf input form, but when I try to do the same thing from Flex, I get an HTTP Internal Server Error after the file is sent, and the file is not saved.

      The form data received by the cffile upload script looks ok, though slightly different from the two sources, so I'm thinking the problem is something in the POST /handler.cfm HTTP/1.1 created by Flex.

      Is there any way I can view and compare these scripts?

      Doug
        • 1. Re: Is there any way to view an HTTP POST request
          doug777 Level 1
          Okay I found the function GetHTTPRequestData(), but the uploaded filename is not in the POST header. Neither is it in the form data from CF (though it is in the form data from Flex) and yet from the CF form, the correct filename is saved on the server. How does CF know the name of the uploaded file on the server?

          Doug
          • 2. Re: Is there any way to view an HTTP POST request
            Level 7
            doug777 wrote:
            > I am trying to upload a picture file using cffile. It works fine from a cf
            > input form, but when I try to do the same thing from Flex, I get an HTTP

            http://www.flex888.com/2007/08/14/9-flex-file-upload-examples-visited.html
            • 3. Re: Is there any way to view an HTTP POST request
              doug777 Level 1
              I can't find any clues at the link you have given.

              I can see from the data received at the cffile upload script that the data from Flex is correct and the same as the data received from CF except that the form has two additional fields, but these are not relevant as I have tried deleting them with StructDelete and there is no difference.

              The code in cffile upload is just:

              <cffile action="upload" filefield="photo" accept="image/jpeg, image/gif" destination="D:inetpub\mysite\images" nameconflict="overwrite">

              I think the problem must be with the destination which is why I get an HTTPStatus Internal Server Error with upload from Flex. With the CF input page, the file is saved correctly with the code as shown.

              From Flex, if I make other changes, I get different errors, but it doesn't matter what nonsense I put in destination, I always get this same HTTPStatus error.

              The destination is a shared server and images folder has read and write privileges for all users.

              I just can't work out what can be wrong.

              Doug
              • 4. Re: Is there any way to view an HTTP POST request
                doug777 Level 1
                I have set up a test on my localhost and I get the same Flex error.

                Also I get an error from the CF test file.

                Test file is:

                <form action="imageupload.cfm" enctype="multipart/form-data" method="post">
                <input type="file" name="photo" size="50">
                <input type="submit" value="Upload">
                </form>

                imageupload.cfm:

                <cffile action="upload" filefield="photo" accept="image/jpeg, image/gif" destination="C:CFusionMX7\wwwroot\images" nameconflict="overwrite">

                I get the error:

                --
                The destination "C:CFusionMX7\wwwroot\images" specified in the CFFILE tag is invalid.

                The destination either does not exist or is not accessible by this tag.
                --

                What is wrong?? The destination certainly exists, so why is it not accessible? The folder has read/write privilege for everyone.

                Doug
                • 5. Re: Is there any way to view an HTTP POST request
                  Level 7
                  doug777 wrote:
                  > I can't find any clues at the link you have given.

                  these were examples as to "how to do it". on the flex end, what are you using to
                  handle the uploads? that link will show you how it's done.
                  • 6. Re: Is there any way to view an HTTP POST request
                    Level 7
                    doug777 wrote:
                    > --
                    > The destination "C:CFusionMX7\wwwroot\images" specified in the CFFILE tag is
                    > invalid.
                    >
                    > The destination either does not exist or is not accessible by this tag.
                    > --

                    why not believe the error message?

                    > What is wrong?? The destination certainly exists, so why is it not accessible?

                    maybe it's really C:\CFusionMX7\wwwroot\images
                    • 7. Re: Is there any way to view an HTTP POST request
                      doug777 Level 1
                      Thanks so much for that, I've looked at this code for so long and changed it so many times I can't see what's right or wrong any more.

                      I think I've finally found the cause of the real problem - why CF won't save the Flex upload - at http://www.adobe.com/devnet/coldfusion/articles/multifile_upload_03.html

                      It seems that the accept type can only be application/octet-stream with a Flex upload and you have to validate the file type afterwards.

                      Hope this is the solution and thanks for your help.

                      Doug
                      • 8. Re: Is there any way to view an HTTP POST request
                        doug777 Level 1
                        Yes this finally is the code that works for Flex uploads.

                        <cfset acceptedFileExtensions = "jpg,jpeg,gif">
                        <cffile action="upload" filefield="photo" accept="application/octet-stream" destination="D:\inetpub\mysite\images" nameconflict="overwrite">
                        <cfset filecheck = listFindNoCase(acceptedFileExtensions, File.ServerFileExt)>
                        <cfif filecheck EQ false>
                        <cffile action="delete" file="D:\inetpub\mysite\images\#File.ServerFile#">
                        </cfif>

                        Thanks again,
                        Doug