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!

preserving filenames in form

Status
Not open for further replies.

snix1

Programmer
Dec 12, 2000
107
US
Hi! I have a form that prompts the user to enter a filename. However, in the action template, when I examine the filename, it is not the same name, but a .tmp file, like
C:\WINNT.SBS\ACF7EAF.tmp.

Is there anyway to access the real file names?
Thanks for your help!

Here is the template:

<form action=&quot;testaction.cfm&quot; name=&quot;thisform&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;>


Enter file1: <INPUT name=&quot;filename1&quot; type=&quot;file&quot; width=&quot;30&quot; ><br><br>
Enter file2: <INPUT name=&quot;filename2&quot; type=&quot;file&quot; width=&quot;30&quot; ><br><br>

<input type=&quot;submit&quot;
value=&quot;send email&quot;>
<input type=&quot;reset&quot;
value=&quot;clear form&quot;>
</form>
 
Well i think that you should take off this from your form tag
enctype=&quot;multipart/form-data&quot;

And by the way what's the purpose of putting it there anyway

;-)
 
Hi! Thanks for your help. I need that because I am uploading files on the action page. If I don't have it, the filename is preserved, but I can't seem to access it as a file. I hope this makes sense. Thanks again.
 
I don't see anything wrong with the code on your form so it must be a ColdFusion problem. What are you using to get the filename (what CF variable)?
 
This is part of the action template:

<cfoutput>filename1 = #filename1#<br>
filename2 = #filename2#<br></cfoutput>
<cfparam name=&quot;filename1&quot; default=&quot;&quot;>
<cfparam name=&quot;filename2&quot; default=&quot;&quot;>
<cffile action=&quot;UPLOAD&quot; filefield=&quot;filename1&quot; nameconflict=&quot;OVERWRITE&quot; destination=&quot;c:\mydir\cfxfile1.txt&quot;>
<cffile action=&quot;UPLOAD&quot; filefield=&quot;filename2&quot; nameconflict=&quot;OVERWRITE&quot; destination=&quot;c:\mydir\cfxfile2.txt&quot;>

By the time I output the filenames they are already .tmp files if I user the enctype on the form tag. If I don't user the enctype, I get the correct file names, but can't upload them. I get the error:
Error in CFFILE tag

The form field specified in the CFFILE tag (FILENAME1) does not contain an uploaded file. Please be sure that you have specified the correct form field name.

Thanks!


 
When I did a file upload in ColdFusion I used something like this for my action page:

<cfif #filename1# is not &quot;&quot;>
<cffile action=&quot;upload&quot; destination=&quot;c:\wherever\&quot; nameconflict=&quot;overwrite&quot; filefield=&quot;filename1&quot;>
<cfoutput>
File1: #File.ServerFileName#.#File.ServerFileExt#
</cfoutput>
</cfif>

<cfif #filename2# is not &quot;&quot;>
<cffile action=&quot;upload&quot; destination=&quot;c:\wherever\&quot; nameconflict=&quot;overwrite&quot; filefield=&quot;filename2&quot;>
<cfoutput>
File2: #File.ServerFileName#.#File.ServerFileExt#
</cfoutput>
</cfif>

But I just started using ColdFusion... If this doesn't work, try asking this in the ColdFusion forum, I'm sure someone there can help.
 
Sorry I didn't answer sooner...so much to do, so little time... anyway, I've done what you said and I do get the names of the files on my server that I upload to. Is there a way to preserve the names of the files that the local user uploads from their PC? When I send an email message with an attachment, the filename I used is the one attached...it is not renamed. I hope this makes sense and thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top