2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>FileUpload basic <i>mode</i> provides a simpler UI as an alternative to default advanced mode.</p>
|
|
|
|
</DocSectionText>
|
2024-05-09 14:46:36 +00:00
|
|
|
<div class="card flex flex-column gap-4 align-items-center justify-content-center">
|
|
|
|
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
|
|
|
<Button label="Upload" @click="upload" severity="secondary" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
2024-05-09 14:46:36 +00:00
|
|
|
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
|
|
|
<Button label="Upload" @click="upload" severity="secondary" />
|
2023-10-15 09:38:39 +00:00
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2024-05-09 14:46:36 +00:00
|
|
|
<div class="card flex flex-column gap-4 align-items-center justify-content-center">
|
2023-02-28 08:29:30 +00:00
|
|
|
<Toast />
|
2024-05-09 14:46:36 +00:00
|
|
|
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
|
|
|
<Button label="Upload" @click="upload" severity="secondary" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
2024-05-09 14:46:36 +00:00
|
|
|
upload() {
|
|
|
|
this.$refs.fileupload.basicUpload();
|
|
|
|
},
|
2023-02-28 08:29:30 +00:00
|
|
|
onUpload() {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2024-05-09 14:46:36 +00:00
|
|
|
<div class="card flex flex-column gap-4 align-items-center justify-content-center">
|
2023-02-28 08:29:30 +00:00
|
|
|
<Toast />
|
2024-05-09 14:46:36 +00:00
|
|
|
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
|
|
|
|
<Button label="Upload" @click="upload" severity="secondary" />
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { useToast } from "primevue/usetoast";
|
|
|
|
const toast = useToast();
|
2024-05-09 14:46:36 +00:00
|
|
|
const fileupload = ref();
|
|
|
|
|
|
|
|
const upload = () => {
|
|
|
|
fileupload.value.basicUpload();
|
|
|
|
};
|
2023-02-28 08:29:30 +00:00
|
|
|
|
|
|
|
const onUpload = () => {
|
|
|
|
toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2024-05-09 14:46:36 +00:00
|
|
|
upload() {
|
|
|
|
this.$refs.fileupload.basicUpload();
|
|
|
|
},
|
2023-02-28 08:29:30 +00:00
|
|
|
onUpload() {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|