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="editListing" DATASOURCE="name">
SELECT * FROM listings
</CFQUERY>
...
<FORM METHOD="POST" ACTION="form2.cfm" enctype="multipart/form-data">
<table>
<tr><td>Picture 1: #pic1#</td><td><input type="file" name="pic1" size="20"></td></tr>
<tr><td>Picture 2: #pic2#</td><td><input type="file" name="pic2" size="20"></td></tr>
<tr><td>Picture 3: #pic3#</td><td><input type="file" name="pic3" size="20"></td></tr>
<tr><td>Picture 4: #pic4#</td><td><input type="file" name="pic4" size="20"></td></tr>
<input type="submit" value="Edit Listing"></td></tr></table>
</FORM>
and on form2.cfm...
<CFSET fileArray = arrayNew(1)>
<cfif Trim(form.pic1) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic1" nameconflict="overwrite">
<CFSET fileArray[1] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic2) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic2" nameconflict="overwrite">
<CFSET fileArray[2] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic3) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic3" nameconflict="overwrite">
<CFSET fileArray[3] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic4) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic4" nameconflict="overwrite">
<CFSET fileArray[4] = lcase(file.clientfile)>
</cfif>
<CFUPDATE TABLENAME="listings" DATASOURCE="name">
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?
Here is what I am doing:
FORM1:
<CFQUERY NAME="editListing" DATASOURCE="name">
SELECT * FROM listings
</CFQUERY>
...
<FORM METHOD="POST" ACTION="form2.cfm" enctype="multipart/form-data">
<table>
<tr><td>Picture 1: #pic1#</td><td><input type="file" name="pic1" size="20"></td></tr>
<tr><td>Picture 2: #pic2#</td><td><input type="file" name="pic2" size="20"></td></tr>
<tr><td>Picture 3: #pic3#</td><td><input type="file" name="pic3" size="20"></td></tr>
<tr><td>Picture 4: #pic4#</td><td><input type="file" name="pic4" size="20"></td></tr>
<input type="submit" value="Edit Listing"></td></tr></table>
</FORM>
and on form2.cfm...
<CFSET fileArray = arrayNew(1)>
<cfif Trim(form.pic1) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic1" nameconflict="overwrite">
<CFSET fileArray[1] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic2) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic2" nameconflict="overwrite">
<CFSET fileArray[2] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic3) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic3" nameconflict="overwrite">
<CFSET fileArray[3] = lcase(file.clientfile)>
</cfif>
<cfif Trim(form.pic4) IS NOT "">
<cffile action="upload" destination="e:/server/homePhotos/" filefield="pic4" nameconflict="overwrite">
<CFSET fileArray[4] = lcase(file.clientfile)>
</cfif>
<CFUPDATE TABLENAME="listings" DATASOURCE="name">
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?