Form field [form.uploadimage] is not a file field

I’m trying to troubleshoot this situation:

  • a file is sent from an android client with a post to a cfm page.
  • a cfm tag in the page try to upload it
  • an exception is thrown: form field [form.uploadimage] is not a file field

I don’t have much control on the client.
The same application with Coldfusion is working.
It seems the file is written but it’s not in image format

I use lucee through apache, with a ProxyPass.
I don’t know where else to look…very important to find a solution as it will block migration

was the form set to multipart/form-data?

1 Like

@Zackster, If we not set enctype=“multipart/form-data”, Coldfusion also throws an error as same as lucee. But, did you see @glasnhost above comment? he said Coldfusion is working.

seeing a code snippet might help, was it the first or the second ?

filefield="form.uploadimage"

or

filefield="uploadimage"

Exactly, CF is working.
here getHttpRequestData():

content
Native Array (byte[])
Raw (truncated) [45,45,42,42,42,42,42,13,10,67,111,110,116,101,110,116,45,68,105,115,11 …truncated]
headers
Struct Entries: 11
accept-encoding string gzip
connection string close
content-length string 84263
content-type string multipart/form-data;boundary=*****
enctype string multipart/form-data
host string 192.168.1.33
uploadimage string /storage/emulated/0/DCIM/IMAGE.jpg
user-agent string Dalvik/2.1.0 (Linux; U; Android 5.1.1; KFFOWI Build/LVY48F)
x-forwarded-for string 192.168.1.35
x-forwarded-host string 192.168.1.33
x-forwarded-server string test.localhost
method string POST
protocol string HTTP/1.1

the only relevant code snippet I’m afraid is this one:

<cffile action="upload" nameconflict="overwrite" filefield="form.uploadimage" destination="/#path#/#filename#">

@glasnhost, Could you please share a stack trace as pic of this issue.

and the corresponding getHttpRequestData from coldfusion

content
binary
headers
struct
Accept-Encoding gzip
ENCTYPE multipart/form-data
connection Keep-Alive
content-length 114354
content-type multipart/form-data;boundary=*****
host 192.168.1.33
uploadimage /storage/emulated/0/DCIM/IMAGE.jpg
user-agent Dalvik/2.1.0 (Linux; U; Android 5.1.1; KFFOWI Build/LVY48F)
method POST
protocol HTTP/1.1

lucee.runtime.exp.ApplicationException: form field [form.uploadimage] is not a file field.
at lucee.runtime.tag.FileTag.getFormItem(FileTag.java:1089)
at lucee.runtime.tag.FileTag.actionUpload(FileTag.java:825)
at lucee.runtime.tag.FileTag.doStartTag(FileTag.java:412)
at uploadfoto_cfm$cf.call(/manage/rooms/uploadfoto.cfm:15)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:880)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:803)
at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:796)
at lucee.runtime.tag.CFTag.doInclude(CFTag.java:317)
at lucee.runtime.tag.CFTag.cfmlStartTag(CFTag.java:243)
at lucee.runtime.tag.CFTag.doStartTag(CFTag.java:177)
at manage.include.bridge_cfm$cf.call(/manage/include/bridge.cfm:11)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:880)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:803)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:217)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:42)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2367)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2357)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2332)
at lucee.runtime.engine.Request.exe(Request.java:43)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1045)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:991)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

@glasnhost, Can you please make sure,once again Is coldfusion working correctly or not as per your code?

why is there a leading space between form. and uploadimage?

sorry my wrong, there is no space.
I did find the line in the code, but still I don’t get why formScope().get returns null…what does it mean?

double checked with a colleague, CF 2016 working, CF11 also

@glasnhost, If the uploaded file is not in the form scope means, it’ll throw an error.

yes, but I see it in the form fieldnames…

  <cflog file="#application.logfile#" text="FORM FIELDS: #form.fieldnames#">

gives:

"INFO","http-nio-8888-exec-9","01/22/2020","16:55:13","","FORM FIELDS: uploadimage"

Local/production lucee machine:
Using: Lucee 5.3.1.102
Apache/2.4.25
On Macos/Centos

oh, can you reproduce the problem on the latest release or snapshot?

@glasnhost, OK fine. Could you please add this condition?

<cfif structKeyExists(form,"uploadimage")>
      <cffile action="upload" nameconflict="overwrite" filefield="form.uploadimage" destination="/#path#/#filename#">
</cfif>

I think, it’ll be solve your issue.

"INFO","http-nio-8888-exec-3","01/22/2020","17:10:23","","key exists!!!!"
"INFO","http-nio-8888-exec-3","01/22/2020","17:10:23","","error form field [form.uploadimage] is not a file field. nomefile:GUASTO1579709423036.jpg log:/storage/emulated/0/DCIM/GUASTO1579709423036.jpg"