Skip to main content
Participant
August 13, 2010
Question

cffileupload - JSON return causing error

  • August 13, 2010
  • 1 reply
  • 1127 views

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">

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

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

This topic has been closed for replies.

1 reply

August 16, 2010

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:

http://forums.adobe.com/message/3057005