Link to home
Start Free TrialLog in
Avatar of frostino
frostinoFlag for United States of America

asked on

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.
Avatar of sajayc
sajayc
Flag of New Zealand image

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?
Avatar of frostino

ASKER

I already have my user uploading files via an FTP client but I want to eliminate that step.
ASKER CERTIFIED SOLUTION
Avatar of billfusion
billfusion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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

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
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.
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!