7 Replies Latest reply on Sep 7, 2014 12:21 PM by BKBK

    cffileupload progressbar shows error although files are uploaded

    DharameshShrivastava

      i am using cf11 developer edition...

       

      i am using cffileupload for uploading multiple files...

      bottom bar says--- uploaded 4 of 4 files

       

      but individual progress bar after reaching to 99% Shows ERROR its color is red

      bottom bar is green

       

       

      how to resolve it ?BKBKColdFusion@

        • 1. Re: cffileupload progressbar shows error although files are uploaded
          BKBK Adobe Community Professional & MVP

          The log files will likely give you a clue. Look, in particular, at the files exception.log, coldfusion-out.log and application.log.

           

          The first thought that comes to mind is: the nameConflict attribute of cffile. You should use either <cffile nameConfilct="overwrite"> or <cffile nameConfilct="makeUnique">. They work as follows:

           

          Overwrite: replaces previously uploaded file of same name.

          MakeUnique: creates a new, unique filename for the upload.

          • 2. Re: cffileupload progressbar shows error although files are uploaded
            DharameshShrivastava Level 1

            i am using cf11 developer edition.

             

            i am using cffileupload for uploading multiple files.

            bottom bar says--- uploaded 4 of 4 files

             

            but individual progress bar after reaching to 99% Shows ERROR its color is red

             

            bottom bar is green

            how to resolve it ?

             

             

            1.CFFileUpload.cfm

             

            <cfajaximport tags="cfmessagebox" />

            <html>

               <head>

                 <title>CFFILEUPLOAD</title>

                   <script type="application/javascript" language="javascript"   src="JS/advanceFileUploadHandling.js"> </script>

               </head>

            <body>

              <cffileupload

                 url="UploadHandler.cfm"

                 extensionfilter=".jpg,.png,.jpeg,.html,.bmp"

                 maxuploadsize="10"

                 title="Upload Html And Image Files"

                 width="700px"

                 addbuttonlabel="select files"

                 uploadbuttonlabel="upload files"

                 deletebuttonlabel="delete selected files"

                 clearbuttonlabel="remove all files"

                  stoponerror ="false"

                 oncomplete="fileComplete"

                 onUploadComplete="uploadComplete"

            />

            </body>

            </html>

             

             

            2.UploadHandler.cfm

             

            <cfsilent>

                   <cffile action="uploadall" filefield="FILEDATA" nameconflict="makeunique" destination ="#getdirectoryFromPath(expandPath("CFFileUpload.cfm"))#

            /Upload/#FORM.FILENAME#"

            />

             

               <cfset returnValue=

                {

                  STATUS=200

                , MESSAGE = "Successfully Uploaded"

                , FILENAME = CFFILE.SERVERFILE

                }>

               

               </cfsilent>

               <cfoutput>#SerializeJSON(returnValue)#</cfoutput>

             

            3.advanceFileUploadHandling.js

             

            var errorFiles = []

            var fileComplete = function(result)

            {

                if(result.STATUS !=200)

                {

                    errorFiles.push(result.FILENAME);

             

                }

               

            }

            var uploadComplete = function()

            {

                var icon = 'info';

                var message =' all were successfully uploaded';

                if(errorFiles.length !=0)

                {

                    icon='error';

                    message='The following files were not uploaded:<br/><br/>';

                   for(i=0; i=errorFiles.length; i++)

                     {

                       message +='  &bull;' + errorFiles[i]+'<br>';

                     }

                   errorFiles=[];

                }

                 if(!Coldfusion.MessageBox.isMessageboxDefined('uploadMessage'))

                 {

                    ColdFusion.MessageBox.Create('uploadMessage','alert','Upload Complete',   message,empty,{icon: icon,                 modal: true});

                }

                else

                {

                    ColdFusion.MessageBox.update('uploadMessage',{icon: icon,modal: true});

                    ColdFusion.MessageBox.updateMessage('uploadMessage',message);

                }

                ColdFusion.MessageBox.show('uploadMessage');

            }

            var empty = function()

            {}

            • 3. Re: cffileupload progressbar shows error although files are uploaded
              BKBK Adobe Community Professional & MVP

              Have you followed my suggestions? If so, what was the result?

              • 4. Re: cffileupload progressbar shows error although files are uploaded
                BKBK Adobe Community Professional & MVP

                Very quickly, something I just noticed, which may or may not have anything to do with the issue: <script type="application/javascript" language="javascript"   src="JS/advanceFileUploadHandling.js"> </script>

                 

                would be better as

                 

                <script type="text/javascript" src="JS/advanceFileUploadHandling.js"> </script>

                • 5. Re: cffileupload progressbar shows error although files are uploaded
                  BKBK Adobe Community Professional & MVP

                  DharameshShrivastava wrote:

                   

                  destination ="#getdirectoryFromPath(expandPath("CFFileUpload.cfm"))#/Upload/#FORM.FILENAME#"

                  The destination should be a directory, not a file. So, use getdirectoryFromPath(expandPath('CFFileUpload.cfm'))#/Upload/. Check beforehand that the directory exists.

                   

                     <cfset returnValue=

                      {

                        STATUS=200

                      , MESSAGE = "Successfully Uploaded"

                      , FILENAME = CFFILE.SERVERFILE

                      }>

                    

                   

                  I doubt whether the structure cffile exists when you are using <cffile action="uploadAll">. That is because you are then uploading multiple files. You should use instead the result attribute, which stores the properties of the uploaded files in an array whose elements correspond to the respective files.

                   

                  In any case, why would you want to output anything in the page UploadHandler.cfm anyway? You never get to see it! The page you currently see is CFFileUpload.cfm. In my opinion, you could just simplify the page content to

                   

                  UploadHandler.cfm

                   

                  <cfsilent>

                         <cffile action="uploadall" filefield="FILEDATA" nameconflict="makeunique" destination ="#getdirectoryFromPath(expandPath('CFFileUpload.cfm'))#/Upload/" />

                  • 6. Re: cffileupload progressbar shows error although files are uploaded
                    DharameshShrivastava Level 1

                    There Seems issue with .SERVERFILE as i checked from log.

                    but what i should use instead?

                    • 7. Re: cffileupload progressbar shows error although files are uploaded
                      BKBK Adobe Community Professional & MVP

                      Cffile.serverfile fails because there is more than one uploaded file. You perhaps missed my explanation. Here it is again:

                       

                      You should use instead the result attribute, which stores the properties of the uploaded files in an array whose elements correspond to the respective files.

                       

                      In any case, why would you want to output anything in the page UploadHandler.cfm anyway? You never get to see it! The page you currently see is CFFileUpload.cfm.

                       

                      You could implement the result attribute as follows:

                       

                      UploadHandler.cfm

                       

                             <cffile action="uploadall" filefield="FILEDATA" nameconflict="makeunique" destination ="#getdirectoryFromPath(expandPath('CFFileUpload.cfm'))#/Upload/" result="uploadResult" />

                       

                      When the cffile action is 'uploadAll', the result attribute is an array of structures. Each element of the array corresponds to an uploaded file, and consists of the information that you would normally expect from the cffile structure. What you could actually do to implement this is to log it. For example, add the line,

                       

                      <cflog file="multiUpload" text="#serializeJSON(uploadResult)#">

                       

                      After you run this, have a look at multiUpload.log