Skip to main content
December 12, 2006
Answered

Automatically Upload client file to CF Server

  • December 12, 2006
  • 1 reply
  • 485 views
I have a scenario where I need to automatically upload a client file to CF Server without using a browser. WebDAV redirector will not do this as I am using https. I've written a simple ColdFusion web service to handle the file once I get it but I have no idea how to consume this service from the client without a user openning a browser. Here's my simple web service code...

<cfcomponent>
<cffunction name="uploadFile" access="remote" returntype="void" hint="Web Service to process secure file upload">
<cfargument name="appUserID" type="string" required="yes">
<cfargument name="appPassword" type="string" required="yes">
<cfargument name="uploadFile" type="binary" required="yes">
<cfargument name="workgroupID" type="string" required="yes">
<cfset uploadDir = #APPLICATION.defaultRootValue# & "/filestores/groups/" & #workgroupID# & "/">
<cffile action="upload" filefield="#uploadFile#" destination="#uploadDir#">
</cffunction>
</cfcomponent>
This topic has been closed for replies.
Correct answer
I found a solution - and yes the best things in life are free! You should check out a tool called curl.
http://curl.haxx.se/

curl is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE and LDAP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other useful tricks. Text curl

1 reply

Inspiring
December 12, 2006
You will have to use SOMETHING that will post the file. One example,
using CF would be to use <cfhttp>. This template then could be tiggered
by some other process, such as a scheduled task, to run when desired.

<cfhttp url="a.web.site/fileAccept.cfc" ...>
<cfhttpparam name="theFile" value="file"...>
....

December 12, 2006
Thanks for the reply but it is important to note that the process will not be initiated from a CF Server. A Client machine will have a file that it needs to automatically upload to my CF Server. The Web Service code can put that file where it needs to go, but I have no idea what to do on the client side to send that file to the ColdFusion Web Service. I can't use a browser, this has to be ran by a task on the client, no end user action required.