Advice on best way to upload a document to a form without saving it to database?
My Java/Springboot/Thymeleaf app has a form called direct bind. On this form there is a modal that pops up when you click a button, in this modal you can attach a file. I am having issues with the submit modal button as I am not sure what to do in my controller... need to append the document to the form & close the modal so that I can continue filling out the form and eventually email the attachment and the forms' input values.
Do I have to create a variable in my model to temporarily hold the attachment until the directBind form is submitted/emailed out?
Here is the modal html:
<div id="modal" class="modal" data-izimodal-title="Upload a Document">
<div id="newRequiredDocForm">
<form enctype="multipart/form-data" th:action="@{/attachDoc}" method="post" th:object="${newFiles}">
<div class="row">
<div class="col-xs-4 col-sm-3 text-right"><label class="modalLabel">Type:</label></div>
<div class="col-xs-4 col-sm-3 text-right">
<label class="modalLabel">File:</label>
</div>
<div class="col-xs-8 col-sm-7">
<input type="file" name="newFiles" id="newFiles" multiple="multiple" style="margin-right:-20px;"/>
</div>
</div>
<br/><br/>
<div style="text-align: right;"><input type="submit" id="attachNewDoc" value="Submit" class="btn btn-docModal"/></div>
</form>
</div>
</div>
Controller:
@RequestMapping(value="/attachDoc")
public String attachDoc (Model model,Document document, DirectBind directBind, @RequestParam("newFiles") MultipartFile newFiles) {
document.setStorage(storageService.store(newFiles));
model.addAttribute("newFiles", newFiles);
return "redirect:/directBind";
}
java hibernate spring-boot thymeleaf
add a comment |
My Java/Springboot/Thymeleaf app has a form called direct bind. On this form there is a modal that pops up when you click a button, in this modal you can attach a file. I am having issues with the submit modal button as I am not sure what to do in my controller... need to append the document to the form & close the modal so that I can continue filling out the form and eventually email the attachment and the forms' input values.
Do I have to create a variable in my model to temporarily hold the attachment until the directBind form is submitted/emailed out?
Here is the modal html:
<div id="modal" class="modal" data-izimodal-title="Upload a Document">
<div id="newRequiredDocForm">
<form enctype="multipart/form-data" th:action="@{/attachDoc}" method="post" th:object="${newFiles}">
<div class="row">
<div class="col-xs-4 col-sm-3 text-right"><label class="modalLabel">Type:</label></div>
<div class="col-xs-4 col-sm-3 text-right">
<label class="modalLabel">File:</label>
</div>
<div class="col-xs-8 col-sm-7">
<input type="file" name="newFiles" id="newFiles" multiple="multiple" style="margin-right:-20px;"/>
</div>
</div>
<br/><br/>
<div style="text-align: right;"><input type="submit" id="attachNewDoc" value="Submit" class="btn btn-docModal"/></div>
</form>
</div>
</div>
Controller:
@RequestMapping(value="/attachDoc")
public String attachDoc (Model model,Document document, DirectBind directBind, @RequestParam("newFiles") MultipartFile newFiles) {
document.setStorage(storageService.store(newFiles));
model.addAttribute("newFiles", newFiles);
return "redirect:/directBind";
}
java hibernate spring-boot thymeleaf
Since the files are uploaded to the server and needs to be stored there (temporarily), how long do you want the files to be retained if the user never submits the main form?
– Andreas
Nov 19 '18 at 23:43
@Andreas I have to store the docs in the server to get them to append to the form and be attached with the emailed form? If the person does not submit the main form, I don't want the files to be in storage. Also, after the email is sent, I no longer need the attachments stored either.
– Stacie
Nov 19 '18 at 23:56
add a comment |
My Java/Springboot/Thymeleaf app has a form called direct bind. On this form there is a modal that pops up when you click a button, in this modal you can attach a file. I am having issues with the submit modal button as I am not sure what to do in my controller... need to append the document to the form & close the modal so that I can continue filling out the form and eventually email the attachment and the forms' input values.
Do I have to create a variable in my model to temporarily hold the attachment until the directBind form is submitted/emailed out?
Here is the modal html:
<div id="modal" class="modal" data-izimodal-title="Upload a Document">
<div id="newRequiredDocForm">
<form enctype="multipart/form-data" th:action="@{/attachDoc}" method="post" th:object="${newFiles}">
<div class="row">
<div class="col-xs-4 col-sm-3 text-right"><label class="modalLabel">Type:</label></div>
<div class="col-xs-4 col-sm-3 text-right">
<label class="modalLabel">File:</label>
</div>
<div class="col-xs-8 col-sm-7">
<input type="file" name="newFiles" id="newFiles" multiple="multiple" style="margin-right:-20px;"/>
</div>
</div>
<br/><br/>
<div style="text-align: right;"><input type="submit" id="attachNewDoc" value="Submit" class="btn btn-docModal"/></div>
</form>
</div>
</div>
Controller:
@RequestMapping(value="/attachDoc")
public String attachDoc (Model model,Document document, DirectBind directBind, @RequestParam("newFiles") MultipartFile newFiles) {
document.setStorage(storageService.store(newFiles));
model.addAttribute("newFiles", newFiles);
return "redirect:/directBind";
}
java hibernate spring-boot thymeleaf
My Java/Springboot/Thymeleaf app has a form called direct bind. On this form there is a modal that pops up when you click a button, in this modal you can attach a file. I am having issues with the submit modal button as I am not sure what to do in my controller... need to append the document to the form & close the modal so that I can continue filling out the form and eventually email the attachment and the forms' input values.
Do I have to create a variable in my model to temporarily hold the attachment until the directBind form is submitted/emailed out?
Here is the modal html:
<div id="modal" class="modal" data-izimodal-title="Upload a Document">
<div id="newRequiredDocForm">
<form enctype="multipart/form-data" th:action="@{/attachDoc}" method="post" th:object="${newFiles}">
<div class="row">
<div class="col-xs-4 col-sm-3 text-right"><label class="modalLabel">Type:</label></div>
<div class="col-xs-4 col-sm-3 text-right">
<label class="modalLabel">File:</label>
</div>
<div class="col-xs-8 col-sm-7">
<input type="file" name="newFiles" id="newFiles" multiple="multiple" style="margin-right:-20px;"/>
</div>
</div>
<br/><br/>
<div style="text-align: right;"><input type="submit" id="attachNewDoc" value="Submit" class="btn btn-docModal"/></div>
</form>
</div>
</div>
Controller:
@RequestMapping(value="/attachDoc")
public String attachDoc (Model model,Document document, DirectBind directBind, @RequestParam("newFiles") MultipartFile newFiles) {
document.setStorage(storageService.store(newFiles));
model.addAttribute("newFiles", newFiles);
return "redirect:/directBind";
}
<div id="modal" class="modal" data-izimodal-title="Upload a Document">
<div id="newRequiredDocForm">
<form enctype="multipart/form-data" th:action="@{/attachDoc}" method="post" th:object="${newFiles}">
<div class="row">
<div class="col-xs-4 col-sm-3 text-right"><label class="modalLabel">Type:</label></div>
<div class="col-xs-4 col-sm-3 text-right">
<label class="modalLabel">File:</label>
</div>
<div class="col-xs-8 col-sm-7">
<input type="file" name="newFiles" id="newFiles" multiple="multiple" style="margin-right:-20px;"/>
</div>
</div>
<br/><br/>
<div style="text-align: right;"><input type="submit" id="attachNewDoc" value="Submit" class="btn btn-docModal"/></div>
</form>
</div>
</div>
<div id="modal" class="modal" data-izimodal-title="Upload a Document">
<div id="newRequiredDocForm">
<form enctype="multipart/form-data" th:action="@{/attachDoc}" method="post" th:object="${newFiles}">
<div class="row">
<div class="col-xs-4 col-sm-3 text-right"><label class="modalLabel">Type:</label></div>
<div class="col-xs-4 col-sm-3 text-right">
<label class="modalLabel">File:</label>
</div>
<div class="col-xs-8 col-sm-7">
<input type="file" name="newFiles" id="newFiles" multiple="multiple" style="margin-right:-20px;"/>
</div>
</div>
<br/><br/>
<div style="text-align: right;"><input type="submit" id="attachNewDoc" value="Submit" class="btn btn-docModal"/></div>
</form>
</div>
</div>
@RequestMapping(value="/attachDoc")
public String attachDoc (Model model,Document document, DirectBind directBind, @RequestParam("newFiles") MultipartFile newFiles) {
document.setStorage(storageService.store(newFiles));
model.addAttribute("newFiles", newFiles);
return "redirect:/directBind";
}
@RequestMapping(value="/attachDoc")
public String attachDoc (Model model,Document document, DirectBind directBind, @RequestParam("newFiles") MultipartFile newFiles) {
document.setStorage(storageService.store(newFiles));
model.addAttribute("newFiles", newFiles);
return "redirect:/directBind";
}
java hibernate spring-boot thymeleaf
java hibernate spring-boot thymeleaf
edited Nov 19 '18 at 23:54


Pritam Banerjee
10.7k64365
10.7k64365
asked Nov 19 '18 at 23:40
StacieStacie
728
728
Since the files are uploaded to the server and needs to be stored there (temporarily), how long do you want the files to be retained if the user never submits the main form?
– Andreas
Nov 19 '18 at 23:43
@Andreas I have to store the docs in the server to get them to append to the form and be attached with the emailed form? If the person does not submit the main form, I don't want the files to be in storage. Also, after the email is sent, I no longer need the attachments stored either.
– Stacie
Nov 19 '18 at 23:56
add a comment |
Since the files are uploaded to the server and needs to be stored there (temporarily), how long do you want the files to be retained if the user never submits the main form?
– Andreas
Nov 19 '18 at 23:43
@Andreas I have to store the docs in the server to get them to append to the form and be attached with the emailed form? If the person does not submit the main form, I don't want the files to be in storage. Also, after the email is sent, I no longer need the attachments stored either.
– Stacie
Nov 19 '18 at 23:56
Since the files are uploaded to the server and needs to be stored there (temporarily), how long do you want the files to be retained if the user never submits the main form?
– Andreas
Nov 19 '18 at 23:43
Since the files are uploaded to the server and needs to be stored there (temporarily), how long do you want the files to be retained if the user never submits the main form?
– Andreas
Nov 19 '18 at 23:43
@Andreas I have to store the docs in the server to get them to append to the form and be attached with the emailed form? If the person does not submit the main form, I don't want the files to be in storage. Also, after the email is sent, I no longer need the attachments stored either.
– Stacie
Nov 19 '18 at 23:56
@Andreas I have to store the docs in the server to get them to append to the form and be attached with the emailed form? If the person does not submit the main form, I don't want the files to be in storage. Also, after the email is sent, I no longer need the attachments stored either.
– Stacie
Nov 19 '18 at 23:56
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384216%2fadvice-on-best-way-to-upload-a-document-to-a-form-without-saving-it-to-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384216%2fadvice-on-best-way-to-upload-a-document-to-a-form-without-saving-it-to-database%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Since the files are uploaded to the server and needs to be stored there (temporarily), how long do you want the files to be retained if the user never submits the main form?
– Andreas
Nov 19 '18 at 23:43
@Andreas I have to store the docs in the server to get them to append to the form and be attached with the emailed form? If the person does not submit the main form, I don't want the files to be in storage. Also, after the email is sent, I no longer need the attachments stored either.
– Stacie
Nov 19 '18 at 23:56