Copy link to clipboard
Copied
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@
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 a
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
There Seems issue with .SERVERFILE as i checked from log.
but what i should use instead?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 +=' •' + errorFiles+'<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()
{}
Copy link to clipboard
Copied
Have you followed my suggestions? If so, what was the result?
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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/" />