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

Help with CFFILE & input type="file".Please!!!! 1

Status
Not open for further replies.

chasbrouck

Programmer
Jan 15, 2002
6
US
Ok heres the problem.

I am passing a filename to anotherpage using the following:
<INPUT NAME="file1" TYPE="file" size="40">

For instance the file selected for file1 is c:\documents\abc.doc

My form then submits this field to anotherpage where I need to evaluate the filename abc.doc. However the value passed to the page is some temporary file name neo.tmp etc...

How can I get the value of my form field (abc.doc) before actually doing the cffile.

Any help would be appreciated.
 
Hi, I was wondering if you ever found a solution to this problem. The same thing is happening to me. Thanks in advance for any wisdom you can provide.
 
Yes, I figured out a away around this. What I did is place a hidden filed on the form called file 1. Then on the file field that the user selects the file to upload I place a javascript command to copy the value of the field to the hidden file:

onChange="document.load.cfile.value=document.load.file1.value"

That wrote the text only value of the file the user selected to the hidden field. You can then evaluate the hidden form filed on the page your submitting to.

Hope this helps. ;-)

Chris
 
I'm trying to employ the solution you provided in this post. However, on the action page Form.TextName has no value.

Can you see my error?

Thanks
Lyndon

<FORM name="UploadForm"
ACTION="AttachLettersSave.cfm"
ENCTYPE="multipart/form-data"
METHOD="POST">
<tr>
<td class="DataLabel" align="right">
Enter File to Attach:
</td>
<td class="DataLabel">
<INPUT NAME="FileName"
SIZE="100"
maxlength="40"
TYPE="FILE"
OnChange="document.Form.TextName.value=document.Form.FileName.value">
<input name="TextName" type="Hidden">
<INPUT TYPE=SUBMIT VALUE="Attach this File">
</td>
</tr>
</FORM>
 
what is the point of knowing this? the file is going to upload anyway. It's included in the header information when you submit the form. if the file isn't what you want you can rename or delete it. using cffile allows you to use a large number of values returned by cffile.


something like
<cffile action = "upload" ...>
<cfif cffile.clientFile neq "abc.doc">
<cffile action = "delete">
this is the wrong file, please upload the right one
</cfif>


We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Got it done using:

cffile action="UPLOAD"
nameconflict="MAKEUNIQUE"
destination="s:\Gaming\"
filefield="Form.FileName">
<cfset mFileName=cffile.serverFile>
<cfset mFileDescription=cffile.clientFile>

Thanks for all the help!

Lyndon
 
Can you see my error?

Lyndon,

<FORM name="UploadForm" ...
OnChange="document.Form.TextName.value=document.Form.FileName.value">
</FORM>

If you change Form to UploadForm, I think it will work:

OnChange="document.UploadForm.TextName.value=document.UploadForm.FileName.value">

Linda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top