Link to home
Start Free TrialLog in
Avatar of bnlf
bnlfFlag for Brazil

asked on

Problem with cfform encryption type + cffile

hi experts. Im having this error trying to upload a file using cffile from a cfform.

Invalid content type: application/x-www-form-urlencoded.  
The cffile action="upload" requires forms to use enctype="multipart/form-data".  
 
i know ppl have fixed this issue using only form instead of cfform because html form you can set enctype by hand. the problem is i cant use form as my using cfselect and cfinput on my code. anyone know a workaround for this?
<cfform action="include_ad.cfm" method="post">
<h2 align="center"> Incluir Anuncio </h2>
<p>Entidade: <cfinput name="entidade" type="text" autosuggest="#entities#" maxresultsdisplayed="6" required="true" message="Campo Obrigatorio" /></p>
<p>Arquivo: <cfinput name="arquivo" type="file"  required="true" message="Campo Obrigatorio" /></p>
<p>Pagina: <cfselect name="nomeAd" bind="cfc:winetag.cfc.model.ad_pageService.getAllItemQuery()" display="name" value="name" bindonload="true" /></p>
<p>Altura: <cfselect name="alturaAd" bind="cfc:winetag.cfc.model.ad_pageService.getAllItemByName({nomeAd})" display="heigth" value="heigth" bindOnLoad="false" />
Comprimento: <cfselect name="comprimentoAd" bind="cfc:winetag.cfc.model.ad_pageService.getAllItemByName({nomeAd})" display="width" value="width" bindOnLoad="false" /></p>
<p><input type="submit" value="Enviar"></p>
</cfform> 
 
----- 
<cfif structKeyExists(form, "arquivo") and len(form.arquivo)>
	   	<cffile action="upload" accept="image/jpg, image/png, image/gif, image/jpeg" filefield="arquivo" destination="#ExpandPath('../../../images/ads/#arquivo#')#" nameconflict="makeunique" >
		<cfimage action="resize" width="#form.width#" height="#form.heigth#" source="#ExpandPath('../../../images/ads/#arquivo#')#" destination="#ExpandPath('../../../images/ads/#arquivo#')#" overwrite="yes">
		<cfset okToContinue = True>
	<cfelse>
		<cfset okToContinue = False>
	</cfif>		

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of azadisaryev
azadisaryev
Flag of Hong Kong 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
Avatar of bnlf

ASKER

thats the problem coldfusion cffrom dont accept enctype.
Avatar of bnlf

ASKER

my bad. must have done something very wrong to think that enctype does not work in cfform :P
thank you that did the trick