PDA

View Full Version : Problem uploading to a CFC using non-standard submit



jnicora
10 Dec 2009, 2:34 PM
I dont have any trouble posting to a .cfm, only a .cfc

have any of you CF guys successfully uploaded files to CFC's this way? It needs to be non-standard (ie: hidden iframe etc)

here is my form:




Ext.onReady(function(){
var frm = new Ext.form.FormPanel({
fileUpload: true,
url: "api.cfc?method=test",
items: [{
xtype: "textfield",
inputType: "hidden",
name: "test",
value: "1"
},{
xtype: "textfield",
inputType: "hidden",
name: "test",
value: "2"
},{
xtype: "textfield",
inputType: "hidden",
name: "test",
value: "3"
},{
xtype: "textfield",
inputType: "hidden",
name: "test",
value: "4"
},{
xtype: "textfield",
inputType: "file",
name: "file"
}],
buttons: [{
text: "Upload",
handler: function(){
frm.getForm().submit({
success: function(){
debugger;
}
});
}
}]
});
frm.render(Ext.getBody());
});

here is my cfc:



<cfcomponent displayname="api" style="rpc">
<cfprocessingdirective suppresswhitespace="yes">
<cfsetting showDebugOutput = "no" >
<cffunction name="test" access="remote" secureJson="yes" returnformat="json">
<cfreturn "hello" />
</cffunction>
</cfprocessingdirective>
</cfcomponent>
here is the stack trace i get:



java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:686)
at coldfusion.runtime.ArgumentCollection.&lt;init&gt;(ArgumentCollection.java:103)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:463)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:453)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:320)
at coldfusion.filter.ComponentFilter.invoke(ComponentFilter.java:183)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.xml.rpc.CFCServlet.invoke(CFCServlet.java:138)
at coldfusion.xml.rpc.CFCServlet.doPost(CFCServlet.java:289)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:619)

jnicora
5 Feb 2010, 1:44 PM
I didn't get back to post what the problem was. As far as I can tell it isn't possible to upload file directly to a cfc, I didn't investigate far enough to know exactly why not. I just created a simple cfm to call for file uploads. Just adding this in case someone else runs into the error.

aconran
5 Feb 2010, 3:08 PM
jnicora -

It's been some time, but I remember that I had an issue with uploading a file to a CFC at some point. What i ended up having to do was pass in the form arg collection as an argument.