cffileupload Tag - Uploading Multiple Files

Back in beta, I had made a post on this new tag in ColdFusion 9. It creates a Flash interface allowing the user to upload multiple files to the server. A pretty easy way to achieve something powerful. Back in beta, there was also a bug with the funtionality. It was that ColdFusion was not automatically passing back Success, Failure messages. With the release now, that has been taken care of, so we can revise the beta code.

Have a look at the Demo

Lets take a look at how simple the code is

fileupload1.cfm:

   view plainprintabout
 <cffileupload
     name = "uploadDemo"
     url="uploadSelectedFiles.cfm"
     progressbar="true"
     addButtonLabel = "Select File(s)"
     clearButtonLabel = "Clear"
     width="500"
     height="400"
     title="Multi File Upload Demo"
10      maxUploadSize="1"
11      maxFileSelect="10"
12      extensionfilter="*.txt,*.jpg,*.png,*.doc"
13      uploadButtonLabel="Upload"
14      >

uploadSelectedFiles.cfm:

   view plainprintabout
 <cffile action = "uploadAll" destination = "c:\temp\" nameConflict = "MakeUnique">
Very Simple, very easy.
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
sandy's Gravatar Cool stuff !!!!!!!
I tried it today only. Its rocking.
Thank you
# Posted By sandy | 1/6/10 4:06 PM
Matthew's Gravatar Apparently it doesn't like variables used in the directory path. I don't get it to work if I use a variable from query.
# Posted By Matthew | 1/13/10 11:44 AM
Kumar's Gravatar Matthew,

I don't know what exactly you are trying, but having the path declaration in a variable worked for me:
<cfset abc = "c:\temp\">

<cffile action = "uploadAll" destination = "#abc#" nameConflict = "MakeUnique">
# Posted By Kumar | 1/13/10 7:43 PM
Matthew's Gravatar The weird thing is I can pass a url variable to it, I can use cfset and pass a variable, but if I use a variable from a query directly it doesn't like it. I just passed a url variable to get it to work. Just remember that with the flash app it will only read hte first variable after the link and will ignore anything passed the &.
# Posted By Matthew | 1/14/10 11:11 AM
Ray Majoran's Gravatar Matthew,

Use URLEncodedFormat around it and it will work. Raymond Camedon had this problem as well and explained that if he used URLEncodedFormat, it worked just fine (and it does).
# Posted By Ray Majoran | 1/16/10 1:04 PM
iphone clone's Gravatar Good job~
# Posted By iphone clone | 1/29/10 11:25 PM
Chris Bowyer's Gravatar I've noticed a lot of folks, even Adobe using a wildcard prefix for the extension filter e.g. extensionfilter="*.txt,*.jpg,*.png,*.doc". It does not make much sense to do this and works fine without them e.g. extensionfilter="txt, jpg, png, doc". Of course, if someone can point out why wildcards should be used, please advise.
# Posted By Chris Bowyer | 3/23/10 9:30 AM
Gilbert's Gravatar In the developer edition of CF9 I still get the red progress bar! Is it possible that this bug is still in the developer edition? Has someone else made the same experience?
# Posted By Gilbert | 6/1/10 6:51 AM
Chris Bowyer's Gravatar @Gilbert I'm not aware there is a bug. Perhaps something else is wrong. The following works fine:

<!--- UPLOAD.CFM --->
<cffileupload
   bgcolor="white"
   extensionfilter="jpg"
   height="400"
   maxuploadsize="1000"
   url="upload_action.cfm"
   width="600" />

<!--- UPLOAD_ACTION.CFM --->
<cftry>
   <cffile
      action="uploadAll"
      destination="#ExpandPath('./uploads')#"
      nameconflict="makeunique" />
   <cfcatch type="any">
      <!--- Redirect to upload.cfm if upload_action.cfm accessed directly --->
      <cflocation url="upload.cfm" statuscode="301" addtoken="no">
   </cfcatch>
</cftry>
# Posted By Chris Bowyer | 6/19/10 1:28 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.5.003.  Design based on ARCLITE by: digitalnature