1 Reply Latest reply on Aug 16, 2010 1:16 PM by redtopia

    cffileupload - JSON return causing error

    David Rotondo

      I have a page has the cffileuload tag.

      The process page simply moves the file to a new location and returns the JSON stuct.


      <cfset str.STATUS = 200>

      <cfset str.MESSAGE = "passed">



      When I run the page I get a red bar error (no number) on the first file and the uploading stops.  However the actual file does move so it is being processed.


      When I comment out the str.STATUS = 200 everything seems to work fine.


      I don't have much understanding of AJAX but I was under the assumption that the STATUS 200 was feedback to the uploader that the page has successfully run.


      According to the documentation I need to output the JSON as above. 


      Any help would be appreciated.


      Running: CF9.0.1

        • 1. Re: cffileupload - JSON return causing error
          redtopia Level 1

          I'm having the same problem. All the examples I've found say that the upload handler should return the following JSON (using your own appropriate values):


          <cfset str.STATUS = 200>
          <cfset str.MESSAGE = "This is a message.">

          <cfoutput>#serializeJSON (str)#</cfoutput>


          but I get an error... the progress bar turns red and when I output the results of the onComplete js function, I get


          Status: [500], message: [Error], file: [temp.txt]


          output comes from the onComplete function (onComplete="uploadFilesComplete"):


          function uploadFilesComplete (file) {

               var msg = '<p>Status: [' + file.STATUS + '], message: [' + file.MESSAGE + '], file: [' + file.FILENAME + ']</p>';
               var obj = document.getElementById ('upload-results');
               if (obj)
                    obj.innerHTML = obj.innerHTML + msg;

          But if I don't return any output, I get:


          Status: [200], message: [Success], file: [temp.txt]


          I wonder if this worked in CF 9.0, but was recently broken in CF 9.0.1. I just ran into another problem after updating to CF 9.0.1 (AJAX cflayoutarea broken) here: