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

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>">
<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">

Open in new window

Who is Participating?
azadisaryevConnect With a Mentor Commented:
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...

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.

galengrayAuthor Commented:

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

Thanks for the prompt reply.  

@galengray: how did it go? do you need mroe help with this?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.