?
Solved

enctype="multipart/form-data" gone!

Posted on 2008-02-07
17
Medium Priority
?
1,248 Views
Last Modified: 2013-12-24
i have the code below in cflayout (center) when it submits i get the following error:

The cffile action="upload" requires forms to use enctype="multipart/form-data".

i have enctype correct as you can see but its getting lost somewhere, how? if i change the cfform to 'form' it works. why does this happen with cfform in cflayout tabs?

<cfoutput>
 
 
  
  <cfform action="includes/imageUploads.cfm" enctype="multipart/form-data" method="post" >
    <!--- Submission flag. --->
    <input type="hidden" name="submitted" value="1" />
    <!---
				Loop over the number of files we are going to
				allow for the upload.
			--->
    <cfloop index="intFileIndex" from="1" to="#REQUEST.FileCount#" step="1">
      <label for="file#intFileIndex#"> File #intFileIndex#: </label>
      <input type="file" name="file#intFileIndex#" id="file#intFileIndex#" /> 
      Alt Tag: <input type="text" name="alt#intFileIndex#" id="alt#intFileIndex#" size="30" />
 
      <br />
    </cfloop>
    <input type="submit" value="Upload Files" />
  </cfform>
</cfoutput>

Open in new window

0
Comment
Question by:pigmentarts
  • 8
  • 8
17 Comments
 
LVL 17

Expert Comment

by:HuyBD
ID: 20839689
It seem the same
<cfoutput>
  <form action="includes/imageUploads.cfm" enctype="multipart/form-data" method="post" >
    <!--- Submission flag. --->
    <input type="hidden" name="submitted" value="1" />
    <!---
                                Loop over the number of files we are going to
                                allow for the upload.
                        --->
    <cfloop index="intFileIndex" from="1" to="#REQUEST.FileCount#" step="1">
      <label for="file#intFileIndex#"> File #intFileIndex#: </label>
      <input type="file" name="file#intFileIndex#" id="file#intFileIndex#" /> 
      Alt Tag: <input type="text" name="alt#intFileIndex#" id="alt#intFileIndex#" size="30" />
 
      <br />
    </cfloop>
    <input type="submit" value="Upload Files" />
  </form>
</cfoutput>

Open in new window

0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839713
There is nothing wrong with your code, you must have a server or other issue.

Here is my test code, I based off your code. It works perfectly.
<cfif isDefined('form.submit')>
	<cfdump var="#form#" />
	<cfabort />
</cfif>
 
<cfoutput>
	<cfform action="dmf.cfm" enctype="multipart/form-data" method="post">
		<cfloop index="intFileIndex" from="1" to="3" step="1">
			<label for="file#intFileIndex#"> File #intFileIndex#: </label>
			<input type="file" name="file#intFileIndex#" id="file#intFileIndex#" /> 
			Alt Tag: <input type="text" name="alt#intFileIndex#" id="alt#intFileIndex#" size="30" />
			
			<br />
		</cfloop>
		<input type="submit" name="submit" value="Upload Files" />
	</cfform>
</cfoutput>

Open in new window

0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839716
Ohh, so my page was called dmf.cfm and submits to itself.

http://code.fraser.id.au/dmf.cfm

This URL is temporary.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
LVL 12

Author Comment

by:pigmentarts
ID: 20839727
> Plucka

did you try it inside a CFLayout tag, i can get it to work outside but when in a cflayoutarea i get the error
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20839742
> Plucka with your code this in my dump

ALT1         [empty string]
ALT2       [empty string]
ALT3       [empty string]
FIELDNAMES       ALT1,ALT2,ALT3,SUBMIT,_CF_CONTAINERID,_CF_NODEBUG,_CF_NOCACHE,_CF_CLIENTID
SUBMIT       Upload Files
_CF_CLIENTID       6C325B28621826EC02D75BA445438CD6
_CF_CONTAINERID       centerA
_CF_NOCACHE       true
_CF_NODEBUG       true
0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839761
oh, what type of <CFlayout are you using?

I just changed the code to use

<cflayout type="hbox">

and it works fine still.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20839765
ok i have done a mock up of the conditions i am using the form in and file1 is not being passed in this example either. could you try on that url? thanks
<cfajaximport tags="cfajaxproxy,cfgrid,cfform,cflayout-border,cftree,cflayout-tab,cfmenu,cftextarea,CFDIV"/>
  <cflayout type="border" >
  <!---top menu--->
  <cflayoutarea position="top">
  <cfinclude template="menus/mainMenu.cfm" />
  </cflayoutarea>
  <!---left menu--->
  <cflayoutarea position="left" name="left" title="Panel Menu" splitter="true" minsize="200"  collapsible="true" size="200" > </cflayoutarea>
  <!---main body--->
  <cflayoutarea position="center" name="center" style=" padding:1em;" > 
   <cfif isDefined('form.submit')>
        <cfdump var="#form#" />
        <cfabort />
</cfif>
 
<cfoutput>
        <cfform action="includes/imageUploads.cfm" enctype="multipart/form-data" method="post">
                <cfloop index="intFileIndex" from="1" to="3" step="1">
                        <label for="file#intFileIndex#"> File #intFileIndex#: </label>
                        <input type="file" name="file#intFileIndex#" id="file#intFileIndex#" /> 
                        Alt Tag: <input type="text" name="alt#intFileIndex#" id="alt#intFileIndex#" size="30" />
                        
                        <br />
                </cfloop>
                <input type="submit" name="submit" value="Upload Files" />
        </cfform>
</cfoutput>
  </cflayoutarea>
  <cflayoutarea position="bottom" name="mainBody" >
  </cflayoutarea>
  </cflayout>

Open in new window

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20839780
the above code i posted will not give the error but in the dump you will see no file is passed
0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839785
Works fine, tweaked only a bit because I dont have menu etc.
<cfif isDefined('form.submit')>
	<cfdump var="#form#" />
	<cfabort />
</cfif>
 
<cfajaximport tags="cfajaxproxy,cfgrid,cfform,cflayout-border,cftree,cflayout-tab,cfmenu,cftextarea,CFDIV"/>
  
<cflayout type="border" >
<!---top menu--->
<cflayoutarea position="top">
<h1>There</h1>
</cflayoutarea>
<!---left menu--->
<cflayoutarea position="left" name="left" title="Panel Menu" splitter="true" minsize="200"  collapsible="true" size="200" > </cflayoutarea>
<!---main body--->
<cflayoutarea position="center" name="center" style=" padding:1em;" > 
<cfif isDefined('form.submit')>
<cfdump var="#form#" />
<cfabort />
</cfif>
 
<cfoutput>
<cfform action="dmf.cfm" enctype="multipart/form-data" method="post">
<cfloop index="intFileIndex" from="1" to="3" step="1">
<label for="file#intFileIndex#"> File #intFileIndex#: </label>
<input type="file" name="file#intFileIndex#" id="file#intFileIndex#" /> 
Alt Tag: <input type="text" name="alt#intFileIndex#" id="alt#intFileIndex#" size="30" />
 
<br />
</cfloop>
<input type="submit" name="submit" value="Upload Files" />
</cfform>
</cfoutput>
</cflayoutarea>
<cflayoutarea position="bottom" name="mainBody" >
</cflayoutarea>
</cflayout>

Open in new window

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20839813
just looking at your example Plucka you now have the same problem as i have.



your code url gives this in the dump. file1 is missing! ytry uploading and no file will be uploaded

ALT1         [empty string]
ALT2       [empty string]
ALT3       [empty string]
FIELDNAMES       ALT1,ALT2,ALT3,SUBMIT,_CF_CONTAINERID,_CF_NODEBUG,_CF_NOCACHE
SUBMIT       Upload Files
_CF_CONTAINERID       center
_CF_NOCACHE       true
_CF_NODEBUG       true

you will find you can not upload using cfform. change it over to just 'form' and you will see it works. but in CF8 form

0
 
LVL 18

Accepted Solution

by:
Plucka earned 2000 total points
ID: 20839815
Ok you are right, no upload happening, but I know why.

ID: 70006

cfinput tags with type="file" are ignored if they are in cfform
tags that are inside containers such as cfdiv, cflayoutarea,
cfwindow, and cfpod. This problem exists because ColdFusion
forms inside AJAX containers are submitted using AJAX and
there is no way to send the file contents using XMLHttpRequest. To
allow file uploading using a form in a ColdFusion AJAX container,
you must use an AJAX file upload control.

http://www.adobe.com/support/documentation/en/coldfusion/8/releasenotes.pdf

Page 3
0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839819
So that's the answer, but not what you wanted to hear im sure.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20839849
Plucka thanks at least i have an answer been going mad for days now. searched the net and found no answer!

ok, so is there ANY way i can do this and keep the form inside the panel without using a IFRAME. i can get it to work using a 'form' but in CF8 all form open in a new window  
0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839860
Hmm, it's going to be tricky. You could eiher pop open a seperate window or use an iframe. There might be a flash / flex option also.

Why don't you like the <iframe method, just for upload fields at least.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 20839877
i have had problems in the pass with iframes and security so stayed away form when for years. maybe its time to revisit.

thank you for taking the time to help me sort this problem Plucka you have been a big help.
0
 
LVL 18

Expert Comment

by:Plucka
ID: 20839884
Happy you know the reason at least.
0
 
LVL 12

Author Closing Comment

by:pigmentarts
ID: 31428792
Very helpful, thanks for taking the time, i know i dont alway fully explain my self correctly.  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Media Temple is thrilled to announce the launch of our new Partner Program, specifically designed to empower digital agencies and adtech platforms by offering white-glove support and exclusive hosting enhancements to optimize their sites and their c…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question