Add PDF type validation to file picker upload
The drop handler validated PDF type but the file picker did not, allowing non-PDF files to bypass client-side validation.
This commit is contained in:
parent
8856daf3c9
commit
87269b9393
1 changed files with 4 additions and 1 deletions
|
|
@ -42,7 +42,10 @@ function openFilePicker() {
|
||||||
async function onFileSelect(e: Event) {
|
async function onFileSelect(e: Event) {
|
||||||
const target = e.target as HTMLInputElement
|
const target = e.target as HTMLInputElement
|
||||||
const file = target.files?.[0]
|
const file = target.files?.[0]
|
||||||
if (file) {
|
if (
|
||||||
|
file &&
|
||||||
|
(file.type === 'application/pdf' || file.name.toLowerCase().endsWith('.pdf'))
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
store.clearError()
|
store.clearError()
|
||||||
const doc = await store.upload(file)
|
const doc = await store.upload(file)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue