télécharge toutes les images s'il y en a plusieurs + texte en blanc

This commit is contained in:
Theophyl Hoguet committed 2023-03-11 17:29:37 +01:00
1 parent 4081048a4b
commit 8649dc4475
1 file changed
+21 -6
+21 -6
View File
@@ -30,9 +30,12 @@ export default defineComponent({
async submitImage() { async submitImage() {
if (this.sent === true || this.file === null) if (this.sent === true || this.file === null)
return; return;
let formData = new FormData(); Array.from(this.file).forEach((file, id) => {
formData.append('file', this.file[0]);
await api.createImage(formData); let formData = new FormData();
formData.append('file', file);
api.createImage(formData);
});
this.sent = true; this.sent = true;
this.$emit('updateImageList'); this.$emit('updateImageList');
this.resetFile(); this.resetFile();
@@ -69,12 +72,12 @@ export default defineComponent({
</script> </script>
<template> <template>
<div> <div>
<label>Files <label>Ajouter une ou plusieurs image(s):
<input id="fileUpload" type="file" @change="handleFilesUpload($event as InputFileEvent)" accept="image/jpeg" <input id="fileUpload" type="file" @change="handleFilesUpload($event as InputFileEvent)" accept="image/jpeg"
multiple /> multiple />
</label> </label>
<button :class="sent ? 'green' : 'normal'" @click="submitImage()">{{ sent ? 'Sent' : 'Submit' }}</button> <button :class="sent ? 'green' : 'normal'" @click="submitImage()">{{ sent ? 'Envoyé' : 'Envoyer' }}</button>
<button v-if="file !== null" @click="resetFile()">Reset</button> <button v-if="file !== null" @click="resetFile()">Reinitialiser</button>
</div> </div>
<h2 v-if="file !== null">Preview :</h2> <h2 v-if="file !== null">Preview :</h2>
<div class="previewBox"> <div class="previewBox">
@@ -90,6 +93,18 @@ img {
border: 1px solid black; border: 1px solid black;
} }
label {
color: white;
}
input {
color: white;
}
h2 {
color: white;
}
.imageLabel { .imageLabel {
display: flex; display: flex;
flex-direction: column; flex-direction: column;