Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-10
9
Medium Priority
?
961 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:frostino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 3

Expert Comment

by:sajayc
ID: 35101502
Hi,

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?
0
 

Author Comment

by:frostino
ID: 35101678
I already have my user uploading files via an FTP client but I want to eliminate that step.
0
 
LVL 6

Accepted Solution

by:
billfusion earned 1500 total points
ID: 35101855
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">
<cfelse>
    <!--- 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">
        <br>
        <input name="submit" type="submit" value="Upload File">  
    </form>
</cfif>
0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 
LVL 3

Expert Comment

by:sajayc
ID: 35101881
Hi,

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.
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35104774
Here is how the docs says you can use CFHTTP to upload files

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=remoteServers_5.html


<cfhttp method="Post"
    url="http://127.0.0.1:8500/myapps/post_test_server.cfm">

 <cfhttpparam type="File"
        name="myfile"
        file="c:\pix\trees.gif">
</cfhttp>

Open in new window

0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35104814
Here is another post that talks about it..

http://cfsearching.blogspot.com/2010/09/cfhttp-file-post-bug-byte.html...
0
 
LVL 1

Expert Comment

by:witsCOMPUTING
ID: 35106008
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:
http://www.forta.com/blog/index.cfm/2007/8/15/Uploading-Large-Files-To-ColdFusion-8
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 35106813
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="http://www.yourserver.com/cfhttptest.cfm" method="post">  
        <cfhttpparam name="myFile" type="file" file="C:\Users\brij\Desktop\binu.zip" mimetype="application/zip" />  
        <cfhttpparam name="BecauseTheFileIsCorruptedWithoutThisField" type="formfield" value="" />  
    </cfhttp>  

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

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 http://www.garyrgilbert.com/tutorials/coldfusion/advanced/cfftp.cfm, but as already suggested about, would need CFFILE tag to give the USER option to choose the file and upload to the server.
0
 

Author Closing Comment

by:frostino
ID: 35107824
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!
0

Featured Post

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question