I'm designing a small application in Spring MVC framework. I have a HTML page where user can upload multiple files.
Here is my HTML file:
<div class="form-group">
<label class="control-label col-sm-4" for="option1">Option 1:</label>
<div class="col-sm-4">
<form:input type="text" path="option1" class="form-control"/>
</div>
<div class="col-sm-4">
<form:input type="file" path="img1" class="form-control" name="img1"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4" for="option2">Option 2:</label>
<div class="col-sm-4">
<form:input type="text" path="option2" class="form-control"/>
</div>
<div class="col-sm-4">
<form:input type="file" path="img2" class="form-control" name="img2"/>
</div>
</div>
based on this code I'm allowing the user to upload 2 files.
Also i have a bean called McqItem.java:
public class McqItem {
private String option1;
private String option2;
private byte[] img1;
private byte[] img2;
//with their getter and setters
}
In my controller i have designed a method where i pass all the data (option1 and option 2) to the bean and from there to the model and save them in my DB
BUT: I don't know how to save my files. prefer to save them in a file.
Can someone tell me how can I save the uploaded files?