I'm not entirely sure why you feel you can't validate that encoding type; the only difference is that it allows UPLOADING.  So you can't validate that one field; you can still do the same thing (validate) with all of your other fields.

One thing to remember is that with CFFILE, you don't get physical access to the upload, other than the fact that you know info about it (filename, size, etc).

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 data about the file upload 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 validation 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 alleviate 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>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to