RE: strange problem when you Trim() file upload form fields

2003-02-03 Thread Joshua Miller
Yes, the file field seems to be the anomaly in using that method ...
I've found you have to actually TRIM() the file upload in the CFFILE tag
to get it to work 100%

This is what I do to catch everything but the file field, then I just
TRIM() all CFFILE uploads


if(HTTP_USER_AGENT contains "msie" AND HTTP_USER_AGENT contains "mac"){
if(isdefined("FORM.fieldnames")){
for(zz=1;zz lte ListLen(FORM.fieldnames);zz=zz+1){
formObj=ListGetAt(FORM.fieldnames,zz);
tmp=evaluate(formObj);
if(tmp DOES NOT CONTAIN ":\WINNT\TEMP\"){
tmpA=StructDelete(FORM,formObj,"TRUE");

tmpB=StructInsert(FORM,formObj,trim(tmp));
}
}
}
}


This assumes a Windows server so you'll have to change the line: if(tmp
DOES NOT CONTAIN ":\WINNT\TEMP\"){ 
to match the temp directory of your OS.

I include this in Application.cfm ... That way it catches every form
submission made. Looking at it here in this message I think it should
check FORM.fieldnames first instead of the HTTP_USER_AGENT - you may
want to change that so it processes slightly faster.

Joshua Miller
Head Programmer / IT Manager
Garrison Enterprises Inc.
www.garrisonenterprises.net
[EMAIL PROTECTED]
(704) 569-9044 ext. 254
 

*
Any views expressed in this message are those of the individual sender,
except where the sender states them to be the views of 
Garrison Enterprises Inc.
 
This e-mail is intended only for the individual or entity to which it is
addressed and contains information that is private and confidential. If
you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying is strictly prohibited. If you 
have received this e-mail in error please delete it immediately and
advise us by return e-mail to [EMAIL PROTECTED]

*


-Original Message-
From: Gyrus [mailto:[EMAIL PROTECTED]] 
Sent: Monday, February 03, 2003 12:38 PM
To: CF-Talk
Subject: strange problem when you Trim() file upload form fields


I had an issue recently that you might remember, where a Mac-based user
of a CMS I've done was having problems using a form. Seems that IE on
the Mac likes adding whitespace or carriage returns to form fields, and
those that I set as boolean values were throwing errors when they're
tested, because the
string "TRUE   " doesn't evaluate as a boolean!

My catch-all solution was to include this code in Application.cfm:


 
   
 

Does the trick, even if it's a little heavy-handed.

Now we've got another problem, in that you can't upload files. An error
gets thrown when you try, saying something like "form.filePath doesn't
contain a file".

Of course by the time you get to the server, form.filePath is something
like "C:\WinNT\Temp\AC0245.tmp" due to the way CF uploads stuff. But I
really can't see any difference between that field's value before or
after the
Trim() code.

Does anyone know what's going on here?

My workaround for the meantime, as all my file upload fields are named
"filePath", is this:


 
  
   
  
 


But naturally I'm curious to know if there's a rational explanation
behind all this...

Gyrus
[EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://norlonto.net
PGP key available


~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4




Re: strange problem when you Trim() file upload form fields

2003-02-03 Thread Gyrus
- Original Message -
From: "Joshua Miller" <[EMAIL PROTECTED]>
> Yes, the file field seems to be the anomaly in using that method ...
> I've found you have to actually TRIM() the file upload in the CFFILE tag
> to get it to work 100%


Thanks a lot for those tips, so good to know you're not the only one with
bizarre-seeming problems like this!

Gyrus
[EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://norlonto.net
PGP key available

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4