Within my app I am giving the users the ability to upload a
file. On a page I have the <cfinput type="file" name="imagefile"
> for the user to select a file, then they will click next to go
on to the next page to continue providing information. How do I
need to set things up so that when the user finally gets to the
last page and clicks "finished" the file will upload? If I put the
<cfinput type="file" name="imagefile" > on the last page
before the finished button it works fine, but when I put it several
pages back it looses it mind and does not know what to do.
Page with file input box:
<cfform>
<cfinput type="file" name="imagefile" >
</cfform>
Next page:
<cfif isdefined("form.imagefile")>
<cfset Session.imagefile ='#form.imagefile#'>
<cfelse>
<cfset Session.imagefile = "">
</cfif>
<cfform method="post" action="finished.cfm"
enctype="multipart/form-data">
BLAH BLAH
</cfform>
Finished page:
I get this error:The form field
someimagename.jpg did not contain a file.
Finished page code.
<cfif isDefined("Session.imagefile") and
#Session.imagefile# neq "" >
<cffile action = "upload" fileField =
"#Session.imagefile#" destination = "#ExpandPath("testimages")#"
nameConflict = "MakeUnique" accept="image/jpg, image/jpeg,
image/pjpeg, image/gif">
</cfif>
Again, if I put the file selection input back to back with
the finished page it works fine, but due to certain other internal
issues, it needs to be several pages back from the finished
page.