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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile update?

Status
Not open for further replies.

swilensky

Programmer
Mar 14, 2001
6
US
I have a form that is used to update a listing. The listing has images that were previously uploaded (successfully).
Here is what I am doing:

FORM1:
<CFQUERY NAME=&quot;editListing&quot; DATASOURCE=&quot;name&quot;>
SELECT * FROM listings
</CFQUERY>
...
<FORM METHOD=&quot;POST&quot; ACTION=&quot;form2.cfm&quot; enctype=&quot;multipart/form-data&quot;>
<table>
<tr><td>Picture 1: #pic1#</td><td><input type=&quot;file&quot; name=&quot;pic1&quot; size=&quot;20&quot;></td></tr>
<tr><td>Picture 2: #pic2#</td><td><input type=&quot;file&quot; name=&quot;pic2&quot; size=&quot;20&quot;></td></tr>
<tr><td>Picture 3: #pic3#</td><td><input type=&quot;file&quot; name=&quot;pic3&quot; size=&quot;20&quot;></td></tr>
<tr><td>Picture 4: #pic4#</td><td><input type=&quot;file&quot; name=&quot;pic4&quot; size=&quot;20&quot;></td></tr>
<input type=&quot;submit&quot; value=&quot;Edit Listing&quot;></td></tr></table>
</FORM>

and on form2.cfm...
<CFSET fileArray = arrayNew(1)>
<cfif Trim(form.pic1) IS NOT &quot;&quot;>
<cffile action=&quot;upload&quot; destination=&quot;e:/server/homePhotos/&quot; filefield=&quot;pic1&quot; nameconflict=&quot;overwrite&quot;>
<CFSET fileArray[1] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic2) IS NOT &quot;&quot;>
<cffile action=&quot;upload&quot; destination=&quot;e:/server/homePhotos/&quot; filefield=&quot;pic2&quot; nameconflict=&quot;overwrite&quot;>
<CFSET fileArray[2] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic3) IS NOT &quot;&quot;>
<cffile action=&quot;upload&quot; destination=&quot;e:/server/homePhotos/&quot; filefield=&quot;pic3&quot; nameconflict=&quot;overwrite&quot;>
<CFSET fileArray[3] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic4) IS NOT &quot;&quot;>
<cffile action=&quot;upload&quot; destination=&quot;e:/server/homePhotos/&quot; filefield=&quot;pic4&quot; nameconflict=&quot;overwrite&quot;>
<CFSET fileArray[4] = lcase(file.clientfile)>
</cfif>
<CFUPDATE TABLENAME=&quot;listings&quot; DATASOURCE=&quot;name&quot;>



The problem is that it is uploading a .tmp files and saving those values to the table. Any ideas on how to get the new files uploaded to the server and inserted into the table?
 
What version of CF are you using? If 4.5, do you have all the updates installed? I know I've seen this discussed in the forums but I don't remember the outcome. I don't see anything wrong with your code so my suspicion is that this may be one of the numerous 4.5 bugs.
 
I am using 4.5. I haven't installed any of the updates, though. Is there one for <cffile>? The uploading and updating of the table works, it is just uploading the wrong file and updating the table with the wrong files name.
 
There are several updates but they usually aren't for specfici tags. I would go to allaire's site and download the most recent patch for 4.5 as there were some significant bugs fixed in the patches they released. I'd say there's a strong chance a applying the patch will take care of it. If not, I'll copy and paste your code on a 4.5 server and see if I get the same results as I don't see anything wrong in the code.

GJ
 
I downloaded the patch for 4.5 and I am still getting the same problem. The download works, the update works, but it is using a temp file instead of the one I specified. Also, if I only want to update one of the files, it deletes the values of the other files (the ones I left as is) from the table.
 
OK - I just checked and the correct file seems to uploading but it just isn't updating with the right value into the table.
 
Are you saying the .tmp file issue is now gone and you're just dealing with the wrong file names in the database? One thing I would mention is that #cffile.clientFile# isn't the name of the file on the server, it's the name of the file the client sent. Although with the name conflict set to &quot;overwrite&quot;, #cffile.clientFile# should be the same as #cffile.serverFile#, I would use the serverFile in case something comes up where it can't name it the same as it was on the client side.

I doubt this is your problem but I mention it just as something that can give you problems. Looking at your code, I just realized that you're using a cfupdate instead of a regular query. I don't think this will work with file inputs since they don't just contain the name of the file, they actually contain the file contents (I believe). I think if you wrote an update query in sql, you will likely get the correct names in the db.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top