Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"os"
"path/filepath"
"strings"

"github.com/gin-gonic/gin"
"github.com/gotify/server/v2/auth"
Expand Down Expand Up @@ -459,7 +460,7 @@ func generateNonExistingImageName(imgDir string, gen func() string) string {
}

func ValidApplicationImageExt(ext string) bool {
switch ext {
switch strings.ToLower(ext) {
case ".gif", ".png", ".jpg", ".jpeg":
return true
default:
Expand Down
9 changes: 4 additions & 5 deletions ui/src/application/Applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const Applications = observer(() => {

useEffect(() => void appStore.refresh(), []);

const validExtensions = ['.gif', '.png', '.jpg', '.jpeg'];

const handleImageUploadClick = (id: number) => {
uploadId.current = id;
if (fileInputRef.current) {
Expand All @@ -71,11 +73,7 @@ const Applications = observer(() => {
if (!file) {
return;
}
if (['image/png', 'image/jpeg', 'image/gif'].indexOf(file.type) !== -1) {
appStore.uploadImage(uploadId.current, file);
} else {
alert('Uploaded file must be of type png, jpeg or gif.');
}
appStore.uploadImage(uploadId.current, file);
};

return (
Expand Down Expand Up @@ -128,6 +126,7 @@ const Applications = observer(() => {
<input
ref={fileInputRef}
type="file"
accept={validExtensions.join(',')}
style={{display: 'none'}}
onChange={onUploadImage}
/>
Expand Down
Loading