4 Replies Latest reply on Sep 21, 2010 6:35 AM by jo_sh

    302 redirect on file upload

    jo_sh

      I am trying to upload a file from flex to coldfusion (component and cfm, I'm trying both).  I've got a progress bar that is displaying the percent loaded to the server through the fileReference.upload method.  When the percent is 100 and the file is 'loaded' flex kicks back an httpStatusError 302.  I can upload the swf to the server and same problem.  This is driving me nuts.  I have even slimmed down the component to output a string (same with the cfm).  Every time I get back a 302.  Does anybody know what could be going on?

        • 1. Re: 302 redirect on file upload
          jo_sh Level 1

          Also, if I make the request into a urlloader instead of a fileRef.upload call I get back a 200 response still no headers though

          • 2. Re: 302 redirect on file upload
            jo_sh Level 1

            Downloaded a network monitor and when I try to upload a file from flex to coldfusion server I get

             

            HTTP/1.1 302 Moved Temporarily
            Connection: close
            Date: Tue, 21 Sep 2010 02:15:51 GMT
            Server: Microsoft-IIS/6.0
            X-Powered-By: ASP.NET
            Set-Cookie: CFID=52893;expires=Thu, 13-Sep-2040 02:15:51 GMT;path=/
            Set-Cookie: CFTOKEN=11010613;expires=Thu, 13-Sep-2040 02:15:51 GMT;path=/
            Set-Cookie: CFID=52893;path=/
            Set-Cookie: CFTOKEN=11010613;path=/

             

            Back as the response headers

             

            When I try to use URLLoader and just get an output with no file upload I get

             

            HTTP/1.1 200 OK
            Connection: close
            Date: Tue, 21 Sep 2010 02:27:03 GMT
            Server: Microsoft-IIS/6.0
            X-Powered-By: ASP.NET
            Set-Cookie: CFID=52892;path=/
            Set-Cookie: CFTOKEN=84507177;path=/
            Content-Type: text/html; charset=UTF-8

             

            What is up with the cookies, it looks like that is the problem.

            • 3. Re: 302 redirect on file upload
              John Hall Level 4

              Could you share a bit of your CF code and Flex code? Many of us do uploads but everyone has their own approach so it would be helpful to see what approach you're using.

              • 4. Re: 302 redirect on file upload
                jo_sh Level 1

                For the flex side...

                 

                var currentFileReference:FileReference = (currentFileObject['flashFileData'] as FileReference);
                           
                           
                            currentFileReference.addEventListener(Event.COMPLETE, indFileComplete);
                               currentFileReference.addEventListener(ProgressEvent.PROGRESS, updateUploadProgress);
                               currentFileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadDataComplete);
                               currentFileReference.addEventListener(HTTPStatusEvent.HTTP_STATUS, uploadHttpStatus);
                               currentFileReference.addEventListener(IOErrorEvent.IO_ERROR, uploadIOError);
                               currentFileReference.addEventListener(SecurityErrorEvent.SECURITY_ERROR, uploadSecurityError);
                              
                            var params:URLVariables = new URLVariables();
                            params.inputfieldname = "Filedata";
                            params.filetype = currentFileObject['selectedFileType'];
                            params.acquisitionid = currentFileObject['acquisitionid'];
                            params.returnurl = currentFileObject['returnurl'];
                               params.filerequired = true;
                               params.requirecommitmentidstart = false;
                               params.comments = currentFileObject['comments'];
                                       
                            var request:URLRequest = new URLRequest(UPLOAD_CFC_ADDRESS+"?CFID="+this.sessionInfo[0]+"&CFTOKEN="+this.sessionInfo[1 ]);
                            request.method = URLRequestMethod.POST;
                            var reqHeadersOne:URLRequestHeader = new URLRequestHeader("pragma", "private");
                            var reqHeadersTwo:URLRequestHeader = new URLRequestHeader("cache-control", "private");
                            var rhArray:Array = new Array();
                            rhArray.push(reqHeadersOne);
                            rhArray.push(reqHeadersTwo);
                            request.requestHeaders = rhArray;
                            request.data = params;
                           
                            currentFileReference.upload(request);

                 

                I've added some new stuff there, the requestheaders stuff and the passing of session info from previousl remoteObject calls.... On the cfc side I have stripped down the function to just an output tag.

                 

                 

                Here is the really weird thing.  Since I started sending the CFID and CFTOKEN variables I have been able to upload using a cfm but not a cfc, the cfc deal just sets new CFID and TOKEN cookies which do not match the ones I get from my previous remoteObject calls.