Link to home
Start Free TrialLog in
Avatar of pigmentarts
pigmentartsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

enctype="multipart/form-data" gone!

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

Avatar of HuyBD
HuyBD
Flag of Viet Nam image

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

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

Ohh, so my page was called dmf.cfm and submits to itself.

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

This URL is temporary.
Avatar of pigmentarts

ASKER

> 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
> 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
oh, what type of <CFlayout are you using?

I just changed the code to use

<cflayout type="hbox">

and it works fine still.
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

the above code i posted will not give the error but in the dump you will see no file is passed
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

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

ASKER CERTIFIED SOLUTION
Avatar of Plucka
Plucka
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So that's the answer, but not what you wanted to hear im sure.
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  
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.
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.
Happy you know the reason at least.
Very helpful, thanks for taking the time, i know i dont alway fully explain my self correctly.