Search code examples
grailsfile-uploadgroovyfile-read

reading from a file using the input type=file in grails


Hi I have the following code in my grails gsp

<form action="upload-script-url" method="post" enctype="multipart/form-data">
    <table class="table"style="width: 75%">
      <tr>
        <td>
            <span  style="font-weight: bold; ">Select the Source File:</span>
            <input size="75" type="file" id="payload" name="payload"/>
        </td>
      </tr>
      <tr>
        <td>
        <input type="submit" class="red" id="Run">Run</button>
        </td>
      </tr>
    </table>
    </form>

I read the form parameters from: here
Are those right parameters in the html form?
Now how should I proceed to read the data from the selected file? do I have to use the apache commons fileupload api ?
Thanks


Solution

  • request.getFile("payload")
    

    and you will get a CommonsMultipartFile