# Passing a file from form to webwork action

**URL:** <https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881>\
**Category:** Jira Server\
**Created:** [April 23, 2019, 12:49pm UTC](https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881 "2019-04-23T12:49:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivana.navratilova](https://avatars.discourse-cdn.com/v4/letter/i/ed8c4c/32.png) [@ivana.navratilova](https://community.developer.atlassian.com/u/ivana.navratilova)\
**Post date:** [April 23, 2019, 12:49pm UTC](https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881/1 "2019-04-23T12:49:38Z")

</div>

I am working on a plugin that requires me to be able to parse an uploaded file - I have created a configuration screen for a plugin that has a small form on it with only input for the file. The thing is, I have no idea how to get the file that user puts into this form once I am inside the Java webwork action class. I have been able to pass variables from form to Java as Strings or numbers, but I havent been able to figure out how to obtain the file.

My .vm file

```auto
    <form class="aui" method="post" action="secure/admin/SpiralImporter.jspa">
        <fieldset>
            <legend><span>File upload</span></legend>
            <div class="field-group">
                <label for="file-upload-example">Upload file</label>
                <input class="upfile" type="file" id="fileImport" name="fileImport">
            </div>
        </fieldset>

        <div class="buttons">
            <button id="submitForm" class="aui-button aui-button-primary">Save</button>
        </div>
    </form>

```

I have a Java class for the action, which gets called correctly.

```auto
public class SpiralImporterAction extends JiraWebActionSupport {
    private File fileImport;

    protected String doExecute() throws Exception {
        //this gets called, but the variable is empty
    }

    public File getFileImport() {
        return fileImport;
    }

    public void setFileImport(File file) {
        this.fileImport = file;
    }
}

```

I have tried accessing the file through the MultiPartWrapper as is shown [here](https://community.atlassian.com/t5/Answers-Developer-Questions/Excel-File-in-Webwork-Action/qaq-p/479203), but it seems to be empty when I submit the form

```auto
MultiPartRequestWrapper wrapper = (MultiPartRequestWrapper)ServletActionContext.getRequest();
File file = wrapper.getFile("fileField");

```

I have also tried the solution shown [here](https://community.atlassian.com/t5/Answers-Developer-Questions/Upload-Files-through-plugin/qaq-p/524453), but it all comes down to the fact that there seem to be no file passed through the request.

Is there some way around it? Or some simpler way to let the user upload a file I could parse and take some actions based on its contents?

---

<div class="post-metadata">

**Author:** ![tjoy](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/tjoy/32/36021_2.png) [@tjoy](https://community.developer.atlassian.com/u/tjoy)\
**Post date:** [April 23, 2019, 1:15pm UTC](https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881/2 "2019-04-23T13:15:21Z")

</div>

Just to be sure,  
Did you try `File file = wrapper.getFile("fileField");`  
or  
`File file = wrapper.getFile("fileImport");` ?  
I believe it should be the later based on your `.vm` file

---

<div class="post-metadata">

**Author:** ![ivana.navratilova](https://avatars.discourse-cdn.com/v4/letter/i/ed8c4c/32.png) [@ivana.navratilova](https://community.developer.atlassian.com/u/ivana.navratilova)\
**Post date:** [April 23, 2019, 1:28pm UTC](https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881/3 "2019-04-23T13:28:17Z")

</div>

Yea that is a copypaste error, but it fails on this line anyway because wrapper is null.

---

<div class="post-metadata">

**Author:** ![SarikaDalalji](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/sarikadalalji/32/38227_2.png) [@SarikaDalalji](https://community.developer.atlassian.com/u/SarikaDalalji)\
**Post date:** [August 16, 2019, 11:29am UTC](https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881/4 "2019-08-16T11:29:05Z")

</div>

I think you missed this encrypt details.

```
  <form action="/secure/testmethods.jspa" method=POST class="aui jim-form" enctype="multipart/form-data">
```

---

<div class="post-metadata">

**Author:** ![dhruv190797](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/dhruv190797/32/37467_2.png) [@dhruv190797](https://community.developer.atlassian.com/u/dhruv190797)\
**Post date:** [December 12, 2019, 7:02am UTC](https://community.developer.atlassian.com/t/passing-a-file-from-form-to-webwork-action/28881/5 "2019-12-12T07:02:18Z")

</div>

Did you find the solution finally?
