0

I have a problem with, upload File in grails. It's a bit weird because it's working in one method but doesn't working in other. Here is my code:

html:

<table>
<tr>
    <td>
        <g:message code="application.image"/>
    </td>
    <td class="ImageCheck">
        <input type="checkbox" id="ImageCheck" name="ImageCheck" onchange="Show();"  />
    </td>
</tr>       
<tr>
    <td class="fileInput_Class" ><input id="inputFile" type="file" name="main"  style="display: none"  onchange=check(this)'/>
</tr>
<table>

Grails:

def ImageUpload()
{                   
    def f = request.getFile('main')
    if(f.fileItem.getSize()!=0)
    {
        "transferring file to specific location"    
    }
}

Working and failing method code looks the same, and here is a stacktrace:

[ERROR] [org.codehaus.groovy.grails.webflow.engine.builder.ClosureInvokingAction] - Exception occured invoking flow action: No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [main]
Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON()
groovy.lang.MissingMethodException: No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [main]
Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON()
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

edit

This solves the problem.

<td class="ImageCheck">
    <g:form method="post" enctype"multipart/form-data">
        <input type="checkbox" id="ImageCheck" name="ImageCheck" onchange="Show();"/>
        <input type="submit" id="submitImage" name="sub" onClick="DoSomething()"/>
    </g:form>
</td>
LEEL
  • 25
  • 1
  • 8

1 Answers1

0

I'm blind :d, this solves the problem:

<td class="ImageCheck">
    <g:form method="post" enctype"multipart/form-data">
        <input type="checkbox" id="ImageCheck" name="ImageCheck" onchange="Show();"/>
        <input type="submit" id="submitImage" name="sub" onClick="DoSomething()"/>
    </g:form>
</td>
LEEL
  • 25
  • 1
  • 8