fix: Changed image extension validation to MIME type validation
This commit is contained in:
@@ -209,7 +209,7 @@
|
|||||||
v-slot="{ file, progress, uploading, openFileSelector }"
|
v-slot="{ file, progress, uploading, openFileSelector }"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="border rounded-md w-fit py-5 px-20">
|
<div class="border rounded-md w-fit py-5 px-20 cursor-pointer" @click="openFileSelector">
|
||||||
<Image class="size-5 stroke-1 text-ink-gray-7" />
|
<Image class="size-5 stroke-1 text-ink-gray-7" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-4">
|
<div class="ml-4">
|
||||||
@@ -540,9 +540,10 @@ const removeImage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validateFile = (file) => {
|
const validateFile = (file) => {
|
||||||
let extension = file.name.split('.').pop().toLowerCase()
|
if (!file.type.startsWith('image/')) {
|
||||||
if (!['jpg', 'jpeg', 'png'].includes(extension)) {
|
const errorMessage = __('Only image file is allowed.')
|
||||||
return 'Only image file is allowed.'
|
toast.error(errorMessage)
|
||||||
|
return errorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
v-slot="{ file, progress, uploading, openFileSelector }"
|
v-slot="{ file, progress, uploading, openFileSelector }"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="border rounded-md w-fit py-5 px-20">
|
<div class="border rounded-md w-fit py-5 px-20 cursor-pointer" @click="openFileSelector">
|
||||||
<Image class="size-5 stroke-1 text-ink-gray-7" />
|
<Image class="size-5 stroke-1 text-ink-gray-7" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-4">
|
<div class="ml-4">
|
||||||
@@ -592,9 +592,10 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const validateFile = (file) => {
|
const validateFile = (file) => {
|
||||||
let extension = file.name.split('.').pop().toLowerCase()
|
if (!file.type.startsWith('image/')) {
|
||||||
if (!['jpg', 'jpeg', 'png', 'webp'].includes(extension)) {
|
const errorMessage = __('Only image file is allowed.')
|
||||||
return __('Only image file is allowed.')
|
toast.error(errorMessage)
|
||||||
|
return errorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,9 +294,10 @@ const removeImage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const validateFile = (file) => {
|
const validateFile = (file) => {
|
||||||
let extension = file.name.split('.').pop().toLowerCase()
|
if (!file.type.startsWith('image/')) {
|
||||||
if (!['jpg', 'jpeg', 'png'].includes(extension)) {
|
const errorMessage = __('Only image file is allowed.')
|
||||||
return 'Only image file is allowed.'
|
toast.error(errorMessage)
|
||||||
|
return errorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user