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

Passing "file name" as a variable

Status
Not open for further replies.

omerdurdu

Programmer
Jul 21, 2001
72
TR
I have a browse page like this:
<from action=&quot;output.cfm&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;>
Browse file:<input name=&quot;FileName&quot; type=&quot;file&quot;>
<input type=&quot;submit&quot; value=&quot;Enter Data&quot;>
</from>

In my output.cfm, I have something like this:
<cffile action=&quot;read&quot; file=&quot;#Form.FileName#&quot; variable=&quot;myxml&quot;>
<cffrom action=&quot;insert.cfm&quot; method=&quot;post&quot; name=&quot;form&quot;>
---
--
--
<input type=&quot;submit&quot; value=&quot;insert&quot;>
</cfform>

The question is how can I pass the file name variable into my insert.cfm. In other words, insert.cfm cannot read the #form.Filename#. what can be wrong.
Thanks for help?
 
Try using #File.ClientName# for the name of the file instead, and see if that works.

I'm not sure, but thats just what I got from reading my manual.. hope it helps ;)

MG
 
Morgan is talking about #file.clientfile# - this is created when you upload a file. Before
you can read the File you have to upload it - have you already done this?

<cffile action=&quot;upload&quot; file=&quot;#form.FileName#&quot; destination=&quot;&quot;....>

then the #file.clientfile# variable will be created.

After that all you have to do in order to read it guessing that the file is a text file is
<cffile action=&quot;read&quot; file=&quot;PATHYouUploadedFileTo\#file.clientfile#...>
Is this what you are looking for?
 
Is it possible doing that without uploading file:
I mean I have a browse form page, I browse a file and I click a button it goes next page,
in this page I have
<cffile action=&quot;read&quot; file=&quot;#form.filename#&quot; variable=&quot;myxml&quot;>

what I would like to do, I would like to pass this #form.filename# to the other page where inserting data into my database.
Is it possible to that without uploading file.
 
The variable you have now #form.FileName# is nothing more than the clients path to the file on their computer. You cannot use that file in any way unless it has been uploaded to the server. Usually once a file is uploaded you insert the #file.clientfile# to a database in order to keep track of which file goes with which record.
#file.clientfile# - Test.txt
#form.filename# - c:\path\Test.txt

Wes
 
omerdurdu:

Whether you do anything with it or not, when the form is submitted, the client uploads the file. Even if you don't do a <cffile action=&quot;upload&quot;>, the file is still temporarily taking up space in your server's memory. You might as well save it to a temporary location using <cffile action=&quot;upload&quot;>, read it using <cffile action=&quot;read&quot;>, then delete it (if you want) using <cffile action=&quot;delete&quot;>.

See Thread232-4967 for a more detailed example of how to do a file upload.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top