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!

How To Use CFILE Upload to Modify and Existing File

Status
Not open for further replies.

awieland

Programmer
Apr 18, 2005
36
0
0
US
I am using the following code to Upload files to the server with no problems, but when I try to use this code to modify an existing file nothing happens on the server and the file is not updated?

Thanks In Advanced

CODE:

<cfif #FORM.hsmFileName# NEQ '' >
<!--- Modify Small Image files --->
<cffile
action="upload"
filefield="smImageFil"
destination="D:\ attributes="Normal"
nameconflict="overwrite">

<cfset oldPathAndName = #FORM.hsmFileName#>
<cfset arrPathAndName = ListToArray(oldPathAndName, '\')>
<cfset fileName = arrPathAndName[ArrayLen(arrPathAndName)]>
<!--- Rename the file to the product number --->
<cfset name1 = "D:\ & #filename#>
<cfset name2 = "D:\ & #form.prod_number# & "_" & "sm" & "." & "JPG">
<cffile action="rename"
source = "#name1#"
destination = "#name2#"
attributes = "Normal">
</cfif>
 
are you getting any errors?

Try wrapping the code with <cftry><cfcatch> to see what CF sees.

Code:
<cftry>
	<cfif #FORM.hsmFileName# NEQ '' >
		<!--- Modify Small Image files  --->
		<cffile action="upload"
				filefield="smImageFil"
				destination="D:\[URL unfurl="true"]www_root\qep\web\images\products\"[/URL]
				attributes="Normal"
				nameconflict="overwrite"
		>    
		
		<cfset oldPathAndName = #FORM.hsmFileName#>
		<cfset arrPathAndName = ListToArray(oldPathAndName, '\')>
		<cfset fileName = arrPathAndName[ArrayLen(arrPathAndName)]>
		
		<!--- Rename the file to the product number  --->    
		<cfset name1 = "D:\[URL unfurl="true"]www_root\qep\web\images\products\"[/URL] & #filename#>
		<cfset name2 = "D:\[URL unfurl="true"]www_root\qep\web\images\products\"[/URL] & #form.prod_number# & "_" & "sm" & "." & "JPG">
		
		<cffile action="rename"
				source = "#name1#"
				destination = "#name2#"
				attributes = "Normal"
			>
	</cfif>
<cfcatch type="any">
	<!--- IF ANYTHING FAILES THEN CF WILL DUMP THE ERROR AND ANYTHING ELSE VIABLE ONTO THE SCREEN --->
	<cfdump var="#cfcatch#" label="ERROR">
</cfcatch>
</cftry>

____________________________________
Just Imagine.
 
GUJUm0del,

I am not receiving any errors. I tryed inserting the <cftry> and <cfcatch> tags and nothing came back. I did not receive an error and the page launched successfully, but the files did not update on the server? Any other suggestion or code you need to see?

Thanks,awieland
 
GUJUm0del,

The permissions on the folder are set for 'Everyone' and 'Full Control', which includes modify? Do you have any other ideas?

Thanks, awieland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top