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:
1 <cffileupload
2 name = "uploadDemo"
3 url="uploadSelectedFiles.cfm"
4 progressbar="true"
5 addButtonLabel = "Select File(s)"
6 clearButtonLabel = "Clear"
7 width="500"
8 height="400"
9 title="Multi File Upload Demo"
10 maxUploadSize="1"
11 maxFileSelect="10"
12 extensionfilter="*.txt,*.jpg,*.png,*.doc"
13 uploadButtonLabel="Upload"
14 >
2 name = "uploadDemo"
3 url="uploadSelectedFiles.cfm"
4 progressbar="true"
5 addButtonLabel = "Select File(s)"
6 clearButtonLabel = "Clear"
7 width="500"
8 height="400"
9 title="Multi File Upload Demo"
10 maxUploadSize="1"
11 maxFileSelect="10"
12 extensionfilter="*.txt,*.jpg,*.png,*.doc"
13 uploadButtonLabel="Upload"
14 >
uploadSelectedFiles.cfm:
1 <cffile action = "uploadAll" destination = "c:\temp\" nameConflict = "MakeUnique">
Very Simple, very easy.
I tried it today only. Its rocking.
Thank you
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">
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).
<!--- 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>