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!

Anyone? How To Modify a File on the Server using CFILE?

Status
Not open for further replies.

awieland

Programmer
Apr 18, 2005
36
0
0
US
I am using the following code to modify or overwrite an existing file on the server, but the code does not when I click the submit button.

Any Ideas, Anyone?

CODE:

<!--- Modify Small Image files --->
<cfif #FORM.hsmFileName# NEQ '' >
<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>

<!--- Form --->

<!--- Small Product Image File --->
<form name="admin_products" action="index.cfm?fuseaction=dsp_admin_products&subaction=mod&processAction=submitMod" method="post" enctype="multipart/form-data" >
<table>
<tr>
<td>
Small Product Image <font color="red"><b>*</b></font> : </td>
<td>
<input class="text" type="File" name="smImageFil" value="Browse..." size="30" tabindex="9" onBlur="return setValue(this, hsmFileName);">
<input type="hidden" name="hsmFileName" value=""> </td>
</tr>

<tr>
<td>
<input type="Submit" name="submit" value=" Modify " tabindex="7">&nbsp;&nbsp;&nbsp;
<input type="Reset" name="reset" value=" Reset ! " tabindex="8">
<input type="Hidden" name="processAction" value="submitMod">
</td>
</tr>
</table>
</form>
 
your javascript function "setvalue()" is not set on your page in the code given. I assume that is supposed to set the value of hsmFileName. I'm still looking into your code but aside from that I'm seeing no other errors. Could you include the javascript? If the javascript is missing or not working that could explain why your file isn't uploading.
Code:
<input class="text" type="File" name="smImageFil" value="Browse..." size="30" tabindex="9" [COLOR=red]onBlur="return setValue(this, hsmFileName);">[/color]


I don't know the answer but my good friend Google does.
 
j4606,

Sorry about that I forgot to include the javascript, here it is.

<script language="JavaScript">
function setValue(obj1, obj2)
{
obj2.value = obj1.value;
return true;
}
</script>

Thanks
 
j4606,

Did you have a chance to see my response?

Thanks, awieland
 
Code:
<input class="text" type="File" name="smImageFil" value="Browse..." size="30" tabindex="9" onBlur="return setValue(this, hsmFileName);">

This used to work in the past, but I'm 99.9% sure that the browsers blocked this a while back. It is a massive security risk when you can choose to upload any file from your user's machine as you could be uploading password files or anything else you wanted.

Hope this helps

Wullie

Fresh Look - Quality Coldfusion 7/Windows Hosting
YetiHost - Coming Soon

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Wullie,

I am already using this code to upload files and it works, but when I want to overwrite the same file with a new file the code does nothing?

Thanks, awieland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top