I have implemented file upload in ReactJS successfully using Yii2 framework and ReactJS. But I will love to validate file type of file before upload. I have come across this and I have tried implementing it as:
<FilePond
ref={ref => this.pond = ref}
files={this.state.coverfiles}
acceptedFileTypes={['images/*']}
fileValidateTypeDetectType={(source, type) => new Promise((resolve, reject) => {
resolve(type);
})
}
onupdatefiles={(fileItems) => {
// Set current file objects to this.state
this.setState({
coverfiles: fileItems.map(fileItem => fileItem.file)
});
}}
required={true}
name={'coverfiles'}
//instantUpload={this.state.sumitted}
allowImageCrop={true}
allowMultiple={false}
processFile={false}
labelIdle={'Drag and Drop your Cover Add Picture or <span class="filepond--label-action"> Browse </span>'}
>
</FilePond>
I need to do this in different cases for images, audio files and video files and I do not know how to resolve the particular file type.