Skip to main content
Participating Frequently
November 25, 2009
Question

How can I grab a remote file and put it on a remote server?

  • November 25, 2009
  • 3 replies
  • 1347 views

I want to grab a file http://somesite/dir1/img.gif and put it here: http://somesite/dir2/img

Any ideas?  I tried cffile and it didn't let me use a url as the source.  I tried cfhttp and it didn't error out, but it didn't copy the file.  Do I need special permissions on that server?  How is that set up?  Thanks!

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    November 30, 2009

    Well I was finally able to get it to work using cfftp.  Here is what did it.  Thanks a lot guys!

    <CFFTP CONNECTION=FTP
                            USERNAME="#mediaFTP_userID#"
                            PASSWORD="#mediaFTP_userPW#"
                            SERVER="#mediaFTP#"
                            ACTION="Open"
                            STOPONERROR="Yes"
                            PASSIVE="Yes">
                           
                            <CFFTP CONNECTION=FTP
                            action="getfile"
                            LOCALFILE="#datadrive#\#url.OID#\content\#newregid#.gif"
                            REMOTEFILE="/ownerdata/#url.OID#/content/#get.regid#.gif"
                            TRANSFERMODE="Binary"
                            PASSIVE="Yes">
                           
                            <CFFTP CONNECTION=FTP
                            action="putfile"
                            LOCALFILE="#datadrive#\#url.OID#\content\#newregid#.gif"
                            REMOTEFILE="/ownerdata/#url.OID#/content/#newregid#.gif"
                            TRANSFERMODE="Binary"
                            PASSIVE="Yes">

    Inspiring
    November 26, 2009

    Are you just moving the file from one directory on the same server to the next? is http://somesite/ the same location? If that is the case, just use CFFILE action=move

    If it is separate physical servers, and if you have access to the destination server, and it is hopefully running CF, you can use CFHTTP to copy the file such as:

    <cfhttp url="http://somesite/dir1/img.gif" path="C:\pathtodir2folder\" file="img.gif" resolveurl="no">

    </cfhttp>

    If you dont have physical access to either your kinda out of luck.

    ilssac
    Inspiring
    November 25, 2009

    You could read it with <cfhttp....> but you really should have permission to do so if you care to be a good netcitizen.

    But to write it you would need to use <cffile....> and a UNC path OR <cfftp....> and use a ftp account.  Of course both of those would require you to have the appropiate permissions.

    If this is just moving files around a server and the ColdFusion server and this "somesite" server are on the same network then <cffile...> and|or <cfdirectory...> would be the easiest, but you will need to run the ColdFusion service|deamon under a domain account that has the appropiate permissions to read and write files accross the network.