Skip to content

Commit

Permalink
Merge pull request #1389 from betagouv/1362-image-formats
Browse files Browse the repository at this point in the history
Ne permet pas de joindre des pièces jointes au formats non-autorisés
  • Loading branch information
alemangui authored Dec 17, 2024
2 parents 224edba + 737d12a commit 853502e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/src/views/ProducerFormPage/AttachmentTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DsfrInputGroup>
<DsfrFileUpload
:label="otherAttachmentsLabel"
:acceptTypes="['image/jpeg, image/gif, image/png, application/pdf']"
:acceptTypes="acceptedTypes"
hint="Taille maximale du fichier : 2 Mo"
@change="addOtherFiles"
v-model="selectedOtherFile"
Expand All @@ -37,6 +37,7 @@ import { ref, computed } from "vue"
import FileGrid from "./FileGrid"
import SectionTitle from "@/components/SectionTitle"
const acceptedTypes = ["image/jpeg", "image/gif", "image/png", "application/pdf"]
const props = defineProps(["externalResults"])
const payload = defineModel()
Expand Down Expand Up @@ -77,6 +78,13 @@ const addFiles = async (files, container, resetModel, defaultData) => {
window.alert(`Le fichier ${files[i].name} dépasse la taille limite de 2 Mo`)
continue
}
const formatIsValid = acceptedTypes.indexOf(files[i].type) > -1
if (!formatIsValid) {
window.alert(
`Le format du fichier ${files[i].name} n'est pas supporté. Merci de joindre un fichier en JPG, GIF, PNG ou PDF.`
)
continue
}
const base64 = await toBase64(files[i])
container.push({
...{
Expand Down

0 comments on commit 853502e

Please sign in to comment.