?
Solved

Retaining form value for input type=file after refresh in Coldfusion

Posted on 2009-03-29
5
Medium Priority
?
1,091 Views
Last Modified: 2012-06-27
In Coldfusion, I am trying to retain the value of a input type=file (for uploading).  When validating my form, all entered values are returned upon submit accept the value for the input type=file field.

How do code to retain value enter or browsed by user or the input type='file' field?

<cfparam name="Form.FileToUpload" default="">
...
<cfif Len(Trim(Form.FileToUpload)) EQ 0>
  <cfset strError = strError & "<li type='square'>Enter or browse for Image to Upload.<br>">
</cfif>
...
<form name="entryForm" id="entryForm" action="entrypublic.cfm" method="post"  enctype="multipart/form-data">
...
<input type="file" name="Form.FileToUpload" value="#HTMLEditFormat(Form.FileToUpload)#" size="35" class="smalltext" tabindex="3" />
...
<input type="hidden" name="submitted" value="yes">
</form>

Open in new window

0
Comment
Question by:galengray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24015206
you can't.
not in cf or any other language - you can't pre-populate an input of type="file". this is a security feature of current HTML standard.

Azadi
0
 

Author Comment

by:galengray
ID: 24015244
Azadi,

How then do you explaln sites that do retain browsed info upon refresh or form validation?

Thanks for the prompt reply.  

--Galen
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 2000 total points
ID: 24015274
if you submit your form to ANOTHER page that does validation, and on that page tell user to press their browser's back button if there are errors, then when they do press the 'back' button, they will return to the from page, and they [usually] will still have all the info they have selected/typed in previously in the form, including their selection in the FILE input.

but you can't pre-populate a blank FILE input field.

if you are using CFFORM tag and your form submits to itself, you can try specifying preserveData="yes" to make the form display submitted values instead of default values. i an not sure if this works with <cfinput type="file">, though...

Azadi
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24070198
@galengray: how did it go? do you need mroe help with this?

Azadi
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question