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
922 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
  • 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 500 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now