Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with multipart/form-data, cffile action="upload"

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I have a form:

<form name=&quot;form&quot; method=&quot;post&quot; action=&quot;upload.cfm&quot; enctype=&quot;multipart/form-data&quot;>
..
<input ..>
<input ..>
<input type=&quot;file&quot; name=&quot;uploadpic&quot; >
..
..
</form>

In upload.cfm, I use a <cffile action=&quot;upload&quot;> tag to save the file. If I refer to any input from the form, i.e. #form.description# however, I get the value twice, separated by commas. This means I get queries such as:
select pic from newsarticles where id = 96,96
which causes problems.

This only happens with submissions from a certain client (IE 5.01). No problems from my machine (IE6.0).

(The server is linux. I didn't set up the server, and I don't spot any easy way to check which version of coldfusion it's running.)
Any ideas?
 
The name you use in your CFFILE tag should be the name of the form field without the &quot;form&quot; prefix or any # signs. Like this:

Here is an excerpt from my form:
<B>Select document file:</B><BR>
<INPUT TYPE=&quot;File&quot; NAME=&quot;MyFile&quot; SIZE=&quot;63&quot; MAXLENGTH=&quot;254&quot;><BR><BR>
<B>Create a title for this document:</B><BR>
<INPUT TYPE=&quot;text&quot; NAME=&quot;DocTitle&quot; SIZE=&quot;75&quot; MAXLENGTH=&quot;254&quot;><BR><BR>
<B>Give a brief description of this document</B><BR>
<INPUT TYPE=&quot;text&quot; NAME=&quot;DocDescription&quot; SIZE=&quot;75&quot; MAXLENGTH=&quot;254&quot;><BR><BR>
<INPUT TYPE=&quot;Submit&quot; NAME=&quot;Submit&quot; VALUE=&quot;Upload File&quot;>   
<INPUT TYPE=&quot;Reset&quot; NAME=&quot;Reset&quot; VALUE=&quot;Clear Form&quot;>

And here is my CFFILE:
<CFSET DocDirectory = &quot;\Documents&quot;>
<CFSET NewID = &quot;#CreateUUID()#&quot;>
<CFSET ProdID = &quot;#Form.ProdID#&quot;>
<CFSET DocTypeID = &quot;#GetDocTypeID.DocTypeID#&quot;>
<CFSET CurrentDateTime =&quot;#CreateODBCDateTime(Now())#&quot;>
<CFSET DocTitle = &quot;#Form.DocTitle#&quot;>

<!--- First, upload the file. --->
<CFFILE ACTION=&quot;UPLOAD&quot;
FILEFIELD=&quot;MyFile&quot;
DESTINATION=&quot;#MyDirectory#&quot;
NAMECONFLICT=&quot;Error&quot;>

HTH Calista :-X
Jedi Knight,
Champion of the Force
 
BTW, if you output the following variables, you can find out what version of CF they are running:

Server.ColdFusion.ProductName (Cold Fusion)
Server.ColdFusion.ProductVersion (4.5.1, 5.0, etc)
Server.ColdFusion.ProductLevel (Professional,Enterprise)

If you look in the documentation for server variables, there are a few others you can make use of. Calista :-X
Jedi Knight,
Champion of the Force
 
currane, if you have multiple checkboxes in your form and all are named the same, cf will pass the value of all SELECTED checkboxes as the comma delimited list; Sylvano
dsylvano@hotmail.com
 
OK, the server is 5.000 professional.

The filefield in cffile tag matches the name on the form.

there are checkboxes, but not multiple select ones.

The effect of the text submitted being doubled, with a comma, happens on all form fields, of type hidden, text, textbox, and only happens from one client.

It seems like some kind of bug, that occurs for multipart forms from this client.

the file which processes the form (for a new record, there is a similar file for updating an existing record, which has the same problem)

<cffile action=&quot;upload&quot;
destination=&quot;#imagepath#&quot;
mode=&quot;777&quot;
nameConflict = &quot;MakeUnique&quot;
filefield=&quot;uploadpic&quot;>

<cfquery datasource=&quot;#dsn#&quot; name=&quot;insertstory&quot;>
INSERT INTO newsarticles(title,type,content,articleadded,pic,contributor)
VALUES('#form.title#','#form.type#','#form.article#','#today#','#ServerFile#','#form.con#')
</cfquery>

results in sql:

INSERT INTO newsarticles(title,type,content,articleadded,pic,contributor) VALUES('Title,Title','General,General','content,content','2002-04-09','ACFGELHPf.gif','ABC,ABC')

(the 'title' input is of type text, the 'content' input is a textbox.) you can see that any of the #form.field# variables are doubled, with commas.

I'm just wondering if anyone has come across anything like this before. Is there something I have to do to make sure that multipart forms are decoded correctly?

eoin.
 
There was a bug in 4.5 where it would duplicate form field entries with a cffile. This was supposedly fixed in 4.5.1 or service pack 2. If I recall correctly, I have seen it come back up from time to time since that release, but I can't remember where or why.

I am trying to locate it now, but I may be totally off here, but I think it had something to do with the placement of the upload file on the form. Try putting the file upload field as the first item in your form and see if that fixes it.

 
Okay, I knew I wasn't hallucinating :) Here is the thread on the Cold Fusion forum at macromedia that discusses it:


or this one:

In a nutshell, look at for any tags like :
'meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1' in the head tag and remove it.

HTH,
Tim P.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top