Go Premium for a chance to win a PS4. Enter to Win

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
?
966 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 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview

926 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