Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile to upload and copy

Status
Not open for further replies.

AlwaysWilling

Programmer
Dec 29, 2005
51
0
0
US
Hi, I am using cffile to upload a image (which works great). But I am having problems with copying that image over.

How can I get the image path that I just uploaded so that I can copy it over?

Thank you.
 
Oh, and I forgot to mention I am uploading the image on one server and then copying it over to another server. Is that doable with cffile upload and copy?

Thanks.
 
How are you connecting to the other server? If you are connecting across the network, then Coldfusion will need access to the other machine. If you can't connect across the network, you should look into CFFTP.

As for getting the filepath of the file, take a look at the docs and they show you the variables you have available to you after the file is uploaded:


Hope this helps

Wullie

Fresh Look - Quality Coldfusion 7/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Another method would be to just use CFFILE to upload your file as normal, and then run a batch or VB file on the server to duplicate the directory every so often. This depends on whether you have access to your Server or not though.

Iether that or instead of using the scripts on Server 1 upload the file and then push it accross, have it just upload the file, then on server 2 have a scheduled script that uses somthing like CFFTP to query the directory on the other serevr and download all the contents.

Rob
 
Hi guys thanks for the replies.

I am now using cffile to upload the image to a folder on server1, and then using cfftp putfile command to push the the image onto the 2nd server.

But I get this error:
Code:
Connection closed without indication.

What does that mean?

Thank you.
 
Wullie, this is my code:

Both servers are setup the same way. One is development and other is production. I want to move the image from development to production.

Code:
<cfif isdefined("FORM.Submit") and FORM.myFile is not "">
	<!--- server one path --->
	<cfset dest = "C:\Inetpub\[URL unfurl="true"]wwwroot\abc\Images">[/URL]
	
	<!--- server two path --->
	<cfset copyDest = "C:\Inetpub\abc\testingUploadIMGs">
	
	<cftry>
        <cffile action="upload" filefield="myFile" destination="#dest#" nameconflict="overwrite" accept="jpg/*">		
		<cfset filename = serverFileName & "." & serverFileExt>
	<cfcatch type="any">
		<cfdump var="#cfcatch#" label="UPLOAD">
	</cfcatch>
	</cftry>
	
	<cfset dest_FullPathName = "#dest#\#filename#">	
	<cftry>
		<cfftp connection="IMGUpload" action="open" username="user@111.11.111.11" password="pw" server="111.11.111.11" passive="yes">
		
		<cfif CFFTP.Succeeded>
			<cfftp connection="IMGUpload" action="putfile" localfile="#dest_FullPathName#" remotefile="#copyDest#" transfermode="auto" passive="yes">
		<cfelse>
			<cfoutput>#CFFTP.ErrorText#</cfoutput>
			<cfabort>
		</cfif>
		
		<cfftp connection="IMGUpload" action="close" server="111.11.111.11" passive="yes">	
	<cfcatch type="any">
		<cfdump var="#cfcatch#" label="FTP">
	</cfcatch>
	</cftry>
	
<cfelse>
	error
</cfif>

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top