Started work on file uploader

This commit is contained in:
neviyn 2021-04-30 00:48:28 +01:00
parent 0e959d60d4
commit b47b534b6f
2 changed files with 18 additions and 1 deletions

View File

@ -22,6 +22,8 @@ class ImageConfigurationProperties {
@NotEmpty @NotEmpty
var types: List<String> = listOf("png", "jpg") var types: List<String> = listOf("png", "jpg")
fun typeListForFormFilter() : String = types.joinToString(",") { ".$it" }
} }
class DirectoryValidator : ConstraintValidator<IsValidDirectory, File> { class DirectoryValidator : ConstraintValidator<IsValidDirectory, File> {

View File

@ -5,6 +5,21 @@
<title>Upload</title> <title>Upload</title>
</head> </head>
<body> <body>
<div class="container">
<div class="row justify-content-center">
<div class="col text-center">
<h1>Upload a new image</h1>
</div>
</div>
<div class="row justify-content-center">
<form action="/" class="mb-3 col-6 text-center" enctype="multipart/form-data" method="POST">
<label class="form-label" for="formFile">Image file</label>
<input class="form-control" id="formFile" name="file" type="file" th:accept="${@imageConfigurationProperties.typeListForFormFilter()}">
<label class="form-label" for="formTags">Image tags</label>
<input class="form-control" id="formTags" placeholder="Tags separated by spaces" type="text">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</body> </body>
</html> </html>