So, you could pass that info in a field on to the next page, for example.
The fact the cffile handles the upload for you is all you care about; once you have the name of the file, and size (for example), you really don't need anything else at that point.
If you need to validate the file itself, you can do that, by doing your compare against the cffile variables (you might wanna only allow certain filetypes for example).
I would recommend you working some client side validated into the process. It would save the user some time if the process was never allowed to happen server side at all if they hadn't done everything they needed to submit (e.g. use REQUIRED, or _javascript_).
Another thing is that you don't need to do any cflocation either, or use the session scope if after the validation, you just included your data posting, and thus you'd be able to eleviate a hassle (in passing that info around).
Robert
-----Original Message-----
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Monday, May 17, 2004 12:42 P
To: CF-Talk
Subject: How to validate form variables with this method including
Encoding: multi-part/form-data
Hi, all...
I know the subject is unclear, but here's the situation.
I'm using CF 4.5...
I validate formfields by submitting a form back to the page containing the
form
and using CFTRY / CFCATCH, then, if everything passes validation, setting
the form variables to session variables and then using CFLOCATION to pass
them to an action page for processing.
I haven't, to this point, used this method, with a from that contains a file
upload field.
Typically, with a form that contains a file upload field, I just don't
validate the fields.
I would, however, like to start validating all form submissions, even those
that contain
file upload fields.
The main question is...how would I pass on the "Encoding type:
multipart/form-date" specification
through the form page itself during verification then send that encoding
info along with the session
variables to the processing page using my typical CFLOCATION
URL="" ?
Here's the code I've set up so far to validate the form entries...
<CFIF IsDefined("Form.Submit")>
<CFTRY>
<CFIF Form.Newsletter_Title is "">
<CFTHROW Type="AddError" Message="Please enter a title for
the newsletter.">
</CFIF>
<CFIF Form.Newsletter_Upload is "">
<CFTHROW Type="AddError" Message="Please use the Browse
button below to locate the newsletter file.">
</CFIF>
<CFLOCK Scope="Session" Type="Exclusive" Timeout="10">
<CFSET Session.Newsletter.Newsletter_Title =
Form.Newsletter_Title>
<CFSET Session.Newsletter.Newsletter_Upload =
Form.Newsletter_Upload>
</CFLOCK>
<CFLOCATION URL = "" AddToken="No">
<CFCATCH Type="AddError">
Error Message...
</CFCATCH>
</CFTRY>
</CFIF>
Thanks,
Rick
Rick Faircloth
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.241 / Virus Database: 262.10.1 - Release Date: 5/16/2004
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

