Copy link to clipboard
Copied
Hi, I just got started in coldfusion and have coldfusion builder 9. I am using FlashBuilder 4 also. I want to make a file upload and don't know how. I would like to use coldfusion to specify how big the file can be and how many can be in the file upload folder.
Copy link to clipboard
Copied
make a file upload
specify how big the file can be
and how many can be in the file upload folder.
I find it a challenging, and useful, exercise. Here is an example in Coldfusion 9. There are 2 CFM files, multiUpload.cfm and uploadFiles.cfm, within the same directory.
The maximum allowed file size for upload is 2 MB. The maximum number of files that can be uploaded each time is 10.
My upload directory is c:\uploads. It has a limit of 30 files. When the limit is reached, the upload button will disappear.
multiUpload.cfm
<cfset MAXUPLOADDIRSIZE = 30>
<cfset isUploadButtonHidden = false>
<cfset maxNoOfFilesSelectedForUpload = 10>
<!--- list the upload dir --->
<cfdirectory action="list" directory="c:\uploads" name="uploadDir">
<cfset noOfFilesinUploadDir = uploadDir.recordcount>
<p>
<cfoutput>
The upload directory currently has #noOfFilesinUploadDir# files.<br>
The limit is #MAXUPLOADDIRSIZE#.<br>
</cfoutput>
</p>
<br>
<p>
To show the current status of the upload folder, you must <a href="javascript:location.reload(true);" title="Refresh page">refresh this page</a> after every upload.
</p>
<br>
<cfset uploadFolderAllowance = MAXUPLOADDIRSIZE - noOfFilesinUploadDir>
<cfif uploadFolderAllowance LTE 0>
<cfset isUploadButtonHidden = true>
<cfset maxNoOfFilesSelectedForUpload = 0>
<cfelseif uploadFolderAllowance LTE 10>
<cfset maxNoOfFilesSelectedForUpload = uploadFolderAllowance>
</cfif>
<cffileupload
url="uploadFiles.cfm"
maxuploadsize="2"
hideUploadButton = "#isUploadButtonHidden#"
progressbar="true"
name="myupload"
addButtonLabel = "Add File"
clearButtonlabel = "Clear"
uploadButtonlabel="Upload"
width=600
height=400
title = "File Upload"
maxFileSelect="#maxNoOfFilesSelectedForUpload#" />
uploadFiles.cfm
<cffile
action = "uploadAll"
destination = "c:\uploads"
nameConflict = "overwrite">
Copy link to clipboard
Copied
In FlashBuilder, which ColdFusion file would I direct it to? Also what script do I use use in FlashBuilder and what ColdFusion code can I use to be able to delete files and show them in FlashBuilder?
Copy link to clipboard
Copied
I just found out I can't use ColdFusion! My hosting plan doesn't support ColdFusion! Thanks Anyway!
Copy link to clipboard
Copied
Might want to take a peek at this thread about CF hosting:
http://forums.adobe.com/thread/620932?tstart=0
Copy link to clipboard
Copied
Right now, I have a good hosting plan that supports php so in the mean time, till I get my hosting plan set-up for coldfusion I think i'll just use php.
Thanks Anyway