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

CFFILE Results Display Problem

Status
Not open for further replies.

tgilbreath

Programmer
Mar 11, 2003
10
US
Hi guys-

Basically, I've got a page that is displaying results from an Access DB that is comprised of inserts from a form. When the information is inserted, CFFILE is also being used to upload the file to a specified directory. However (and I've seen this problem in other forums, but NONE of the responses made any sense), when I try to call the uploaded filename (to make a link where the file can be immediately viewed), I get the following:

--------------------------------
C:\CFusionMX\runtime\servers\default\SERVER-INF\temp\--------------------------------

The neotmp.tmp file consists of 5 numbers that change with each file uploaded. I have seen the first response that says to make sure CF delimiters are not being used in the fileform call, which they are not. The db insert is working fine, as is the upload. It's simply calling back the name of the uploaded file that is producing this anamoly. Here is the code, any help would be very greatly appreciated!!!

=======================================================
UPLOAD/INSERT FORM
=======================================================
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<cfquery name=&quot;ClientPopulate&quot; datasource=&quot;ftp&quot;>
SELECT * FROM Clients
</cfquery>
<body>
<cfform action=&quot;file_upload.cfm&quot; enctype=&quot;multipart/form-data&quot;>
<table width=&quot;350&quot; border=&quot;0&quot;>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Upload File:</strong></td>
<td><input type=&quot;file&quot; name=&quot;FileName&quot;></td>
</tr>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>File Title:</strong></td>
<td><input type=&quot;text&quot; name=&quot;FileTitle&quot;></td>
</tr>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>File Type:</strong></td>
<td>
<select name=&quot;FileType&quot;>
<option selected>Choose Type</option>
<option>Adobe PDF</option>
<option>Image - GIF</option>
<option>Image - JPEG</option>
<option>Document - MS Word</option>
</select>
</td>
</tr>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Client:</strong></td>
<td>
<cfoutput query=&quot;ClientPopulate&quot;>
<select name=&quot;FileClient&quot;>
<option selected>Choose Client</option>
<option>#ClientName#</option>
</select>
</cfoutput>
</td>
</tr>
<tr>
<td colspan=&quot;2&quot;>
<input type=&quot;submit&quot; value=&quot;Upload&quot;>
</td>
</tr>
</table>
</cfform>
</body>
</html>
=======================================================
UPLOAD/INSERT PROCESSING PAGE
=======================================================
<cffile action=&quot;upload&quot;
filefield=&quot;Form.FileName&quot;
destination=&quot;C:\Inetpub\dhilton\ftp\pdf\&quot;
nameconflict=&quot;MakeUnique&quot;>

<cfset FileName=&quot;#cffile.serverFile#&quot;>

<cfinsert datasource=&quot;ftp&quot; tablename=&quot;Files&quot; dbtype=&quot;ODBC&quot; formfields=&quot;FileName, FileTitle, FileType, FileClient&quot;>

<cflocation url=&quot;start_clientdhatemplate.cfm&quot;>
========================================================
FILE VIEWING PAGE
========================================================
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body>

<cfquery name=&quot;FileList&quot; datasource=&quot;ftp&quot;>
SELECT * FROM Files
</cfquery>
<table width=&quot;600&quot; border=&quot;0&quot;>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>[<a href=&quot;users.cfm&quot;>Users</a>]   [<a href=&quot;upload_select.cfm&quot;>Upload</a>]</strong></td>
</tr>
</table>
<br>
<table width=&quot;750&quot; border=&quot;0&quot;>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Title</strong></td>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Name</strong></td>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Type</strong></td>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Client</strong></td>
</tr>
<cfoutput query=&quot;FileList&quot;>
<tr>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;>#FileTitle#</td>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><a href=&quot;../ftp/pdf/#FileName#&quot;>#FileName#</a></td>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;>#FileType#</td>
<td><font face=&quot;verdana&quot; size=&quot;1&quot;>#FileClient#</td>
</tr>
</cfoutput>
</table>
</body>
</html>
=======================================================
 
I think some of your problem is stemming from your understanding of what the form is actually passing in the
Code:
<input type=&quot;file&quot; ...>
.

While, within the form, it displays the path that the user browsed to... what actually ends up being passed in
Code:
#FORM.FileName#
is the contents of the file itself.

Not exactly what you want to store in the FileName field of your database record, I would guess. But that's exactly what's happening in your CFINSERT line:
Code:
<cfset FileName=&quot;#cffile.serverFile#&quot;>

<cfinsert datasource=&quot;ftp&quot; tablename=&quot;Files&quot; dbtype=&quot;ODBC&quot; formfields=&quot;FileName, FileTitle, FileType, FileClient&quot;>
Even though you're setting #FileName# to the name of the file through your CFSET, the CFINSERT is still looking at the FORM scope... in which #FileName# contains the entire file contents.

You might be able to get away with simply revising the CFSET to set the value in the FORM scope...
Code:
<cfset FORM.FileName=&quot;#cffile.serverFile#&quot;>
but, ultimately, you really want to use the CFQUERY tag and run your own INSERT statement, rather than use CFINSERT. I haven't used CFINSERT for over three years... it's just not flexible enough.
Using CFQUERY is nearly as easy, though... something like:
Code:
<cfquery datasource=&quot;ftp&quot; dbtype=&quot;ODBC&quot;>
   INSERT into Files
   ('FileName, FileTitle, FileType, FileClient')
   VALUES
   ('#cffile.serverFile#','#FORM.FileTitle#','#FORM.FileType#','#FORM.FileClient#')
</cfquery>
should get you close.


Also... as a side note, you're probably not getting what you expected from the following block:
Code:
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Client:</strong></td>
<td>
<cfoutput query=&quot;ClientPopulate&quot;>
<select name=&quot;FileClient&quot;>
<option selected>Choose Client</option>
<option>#ClientName#</option>
</select>
</cfoutput>
</td>
This would produce n number of select boxes, each with a single client listed.
Try putting the CFOUTPUTs between the SELECT tags:
Code:
<td><font face=&quot;verdana&quot; size=&quot;1&quot;><strong>Client:</strong></td>
<td>
<select name=&quot;FileClient&quot;>
<option selected>Choose Client</option>
<cfoutput query=&quot;ClientPopulate&quot;>
<option>#ClientName#</option>
</cfoutput>
</select>
</td>
that way you get one selectbox, with n number of clients listed.


-Carl
 
Carl-

Thanks, that was it exactly...and yes, I'll convert the insert to the CFQUERY. I was misunderstanding the scope of the upload contents.

And regarding the select box, that was a mistake on my part, I meant to put the output tags around the option tag, thanks for pointing that out though!!

Thanks again!!

Tim

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top