Here is the HTML component code snippet:
<a-upload-dragger
name="file"
:multiple="true"
:customRequest="uploadfiles"
@change="handleChange">
</a-upload-dragger>
To handle the customRequest function, you can use the following method:
uploadfiles({ onSuccess, onError, file }) {
this.upload(file)
.then(() => {
onSuccess(null, file);
})
.catch(() => {
console.log('error');
});
};
The file object has properties like name, lastModified, size, type, etc.
name: "YourFileName.txt"
lastModified: ...
lastModifiedDate: ...
webkitRelativePath: ""
size: 24
type: "text/plain"
uid: "vc-upload-xxxxxx..."
You have the flexibility to create your own upload function as needed.
Additionally, you can track the status changes of the file upload progress using the handleChange function:
handleChange(info) {
const status = info.file.status;
if (status !== 'uploading') {
// Show update progress console.log(info.file, info.fileList);
}
if (status === 'done') {
// Show success message
} else if (status === 'error') {
// Show error message
}
}