Can't delete uploaded file.
I made a simple upload form and trying to use the cffile to upload, rename and delete the original file. So the process goes like this.
Step 1: User will browse their computer to grab the picture they would like to upload (ex: picture1.jpg). then hit upload button.
Step 2: Use one cffile that would upload the file. (picture1.jpg)
Step 3: Another cffile would rename the original picture to the userID that i have in the database. (renamed to "1.jpg")
Step 4: Then another cffile to delete the orginial picture file, so there's only 1 picture which is the one the cffile renamed. (1.jpg on server, picture1.jpg deleted)
hope that makes sense. here's the code i used to try and make this happen.
I always get an error on the deleting part of the code.
=========== Upload form ===============
<cfform enctype="multipart/form-data" method="post">
<h1>Picture Upload Form</h1>
<cfinput type="file" name="fileUpload" required="yes" message="- Must add file!" />
<cfinput type="hidden" name="UserID" value="#URL.User#">
<cfinput type="submit" name="file_submit" value="Upload File" /><br />
</cfform>
<cfif isDefined("fileUpload")>
<cffile action="upload"
fileField="fileUpload"
destination="C:\ColdFusion9\wwwroot\website\pimages"
accept="image/jpg,image/jpeg,image/pjpeg"
nameconflict="makeunique">
<font size="+1">The file has been uploaded.</font>
<cffile action="rename"
source="#FORM.FileUpload#"
destination="C:\ColdFusion9\wwwroot\website\pimages\#FORM.UserID#.jpg">
<cffile action="delete"
file="C:\ColdFusion9\wwwroot\website\pimages\#FORM.FileUpload#">
=========== Upload Form ===========
