Reputation: 73
Is it possible to upload a file, and a text input in the same form (i.e., a single submit button click triggers both to be submitted).
<form action="DAOserv" method="POST">
<div class="form-group col-lg-8">
<textarea name="textInput" placeholder="text"
class="form-control" rows="11"></textarea>
<label for="LInputFile">SQL File</label> <input type="file"
id="SQLInputFile">
</div>
<button name="submitButton" type="submit" class="btn btn-primary">Submit</button>
</form>
In other words, is this snippet of code feasible?
If yes, how would I go about getting the text from the file into a string using AJAX and Java Servlets?
Upvotes: 0
Views: 274
Reputation: 4010
You can't get the content of a file via Javascript. Consequently, you can't send the file contents with AJAX.
Upvotes: 1