Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to handle csv file upload?

Hi, I am developing a plugin that allows you to bulk create users on a server based on the data in a csv file. I've managed to get a velocity template showing with a form, as such:

<form id="form" action="#">                
<label for="file-input">Choose CSV file:</label>                
<input type="file" id="file-input" name="file-input" accept=".csv">                
<button type="submit" value="Submit">Submit</button>            

However, I'm stuck on the action java class. How do I handle the csv file upon submitting the form (extract the data from the csv file)? 

1 answer

You form needs to be 


And your action should implement "ServletRequestAware" 

And you should receive a "MultiPartRequestWrapper" really into your action class (injected by xwork framework)

Then it is a matter of simple calls to "MultiPartRequestWrapper" instance to get uploaded file(s). I am pretty sure you can figure out the rest


Hey Alex, thanks for replying!

It says here that ServletRequestAware is deprecated. I'm guessing I should do something like the answer in this question?

Yes, you can use 


Hi Alex, I've tried following this solution but I still can't get it to work. It just refreshes my page and nothing is logged. What could be the issue?

Your "action" attribute should point at the action (class mapping) that handles the upload... not at #

Thanks for replying Alex. The action attribute of the form does point to the servlet class.


Form from Velocity template:

<form class="aui" id="form" enctype="multipart/form-data" method="POST" action="${req.contextPath}/my-servlet">                
<label for="file-input">Upload CSV file:</label>                
<input class="upfile" type="file" id="file-input" name="file-input" accept=".csv">                
<button id="submit-btn" type="submit" value="Submit">Submit</button>            



<servlet key="my-servlet" class="com.dso.intern.plugin.MyServlet" name="Bulk User Creation Tool Servlet">        
<description key="my-servlet-description">#</description>        

First of all the patterns dont match ("my-servlet" vs "/bulk-user-creator") and second, is that the mapping to servlets declared in plugins starts with 


Check Atlassian documentation on this... 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

196 views 6 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you