How do I use CFFTP to allow a user to upload a file to a folder on the server?

I would like to allow a user to upload a file to my server via CFFTP in order to get around my shared hosting upload limit.  I'm told this is an option but have not used CFFTP yet and the CF documentation isn't very clear to me.
Who is Participating?
billfusionConnect With a Mentor Commented:
What you need to use is CFFile not CFFTP.  Here is an example from Adobe; make sure to change the destination to whatever fits your needs:

<!--- Windows Example --->
<!--- Check to see if the Form variable exists. --->
<cfif isDefined("Form.FileContents") > 
    <!--- If TRUE, upload the file. --->
    <cffile action = "upload"  
        fileField = "FileContents"  
        destination = "c:\files\upload\"  
        accept = "text/html"  
        nameConflict = "MakeUnique">
    <!--- If FALSE, show the Form. --->
    <form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>  
        name="uploadForm" enctype="multipart/form-data">
        <input name="FileContents" type="file">
        <input name="submit" type="submit" value="Upload File">  

Have worked with this tag recently.
The cfftp tag will only FTP a file from the web server to another location.
If you want your client to be able to ftp to your server, you have to give them the ftp username and password.  Then they use an FTP client like Filezilla to upload files.

Do you know what the upload limit is?
frostinoAuthor Commented:
I already have my user uploading files via an FTP client but I want to eliminate that step.
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


The other option is to use CFFILE tag.
What OS is the server?  What is the file size limit?
Usually there is no limit for uploading files.
Brijesh ChauhanStaff IT EngineerCommented:
Here is how the docs says you can use CFHTTP to upload files

<cfhttp method="Post"

 <cfhttpparam type="File"

Open in new window

Brijesh ChauhanStaff IT EngineerCommented:
Here is another post that talks about it..
Uploading via cffile upload action not work for large files. When you upload files using cffile tag, it stores file in Server memory which will blow up if you try to upload large file. ColdFusion 8 and 9 have another function GetHTTPRequestData which can be use to upload large files. cfftp has nothing to do with file upload from client to server and it will also not work for large files.

You can read more about GetHTTPRequestData at:
Brijesh ChauhanStaff IT EngineerCommented:
Guys, I completely misread the Question, instead of CFFTP I read it as CFHTTP.. sorry about that...

Well you can actually use CFHTTP to post files from one server to another, basically if you have CF running on your local system then you can use it to post files to a server

on your local system have a test.cfm , which will post a file on your local system to the server. On the server, create a file called cfhttptest.cfm which will list to such request..

Your Local system code

 <cfhttp url="" method="post">  
        <cfhttpparam name="myFile" type="file" file="C:\Users\brij\Desktop\" mimetype="application/zip" />  
        <cfhttpparam name="BecauseTheFileIsCorruptedWithoutThisField" type="formfield" value="" />  

Open in new window

Your Server Code

<cfif structKeyExists(FORM, "myFile")>  
    <cffile action="upload" destination="#ExpandPath('.')#" nameconflict="overwrite" />  
    <cfzip action="list" file="#cffile.serverDirectory#/#cffile.serverFile#" name="result" />  
    <cfdump var="#result#" label="Zip File Contents" />  

Open in new window

You have to run the cfm from your local system and it will upload the file to the server.


You can read about CFFTP here, but as already suggested about, would need CFFILE tag to give the USER option to choose the file and upload to the server.
frostinoAuthor Commented:
I may or may not use this solution.  I was aware of CFFILE and have used it but I was misinformed about the file limit using this tag.  My hosting provider recommended a flash or java uploader and I'm going to look into that.  Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.