Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help!

Explorer ,
Apr 12, 2010 Apr 12, 2010

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.

1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 13, 2010 Apr 13, 2010

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">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 13, 2010 Apr 13, 2010

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 23, 2010 Apr 23, 2010

I just found out I can't use ColdFusion! My hosting plan doesn't support ColdFusion! Thanks Anyway!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 24, 2010 Apr 24, 2010

Might want to take a peek at this thread about CF hosting:

http://forums.adobe.com/thread/620932?tstart=0

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2010 Apr 24, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources