<--- I created my form to insert a new player into my hockey database. What I wanted to do was upload a photo of the player at the time I was inserting his generic data (ie. Name, Jersey Number, Position Id). Notice I used enctype="multipart/form-data in the form tag so that the file would upload. --->
<form action="insertplayer.cfm" method="post" enctype="multipart/form-data">
Add a new player:
<input type="text" name="JerseyNumber" maxlength="3">
Position:
<select name="PositionId">
<cfoutput query="getpositions">
<option value="#PositionId#">#PositionName#</option>
</cfoutput>
</select>
Player Name:
<input type="text" name="Name" maxlength="50">
Photo:
<input type="file" name="Photo">
<input type="submit" value="Add Player">
</form>
<--- This is the action page that inserts generic player data from the form. The first thing I do is upload the image file from the form. --->
<CFFILE ACTION="Upload" FILEFIELD="Photo" DESTINATION="e:\sitedir\photos\" NAMECONFLICT="MakeUnique">
<--- Here, I insert the form data into the database. Notice I used #file.clientfile# to request the file name of the photo. This is the problem I was having. By not using #file.clientfile#, I was getting a "filename.tmp" entry in the database. -->
<cfquery name="insert" datasource="dsn">
insert into team (PositionId, JerseyNumber, Name, Photo)
values
('#Form.PositionId#','#Form.JerseyNumber#',
'#Form.Name#','#file.ClientFile#')
</cfquery>
I couldn't find the post that taught me this again. I'll keep searching and post it again as soon as I do. Special thanks to whoever posted it though!