我正在尝试将初始图像加载到材质ui dropzone。我有base64格式的图像,我想将它们作为initialFiles加载到dropzone。
我尝试使用intialFiles选项按照以下网址实施此操作。但是仍然没有运气,也没有出现任何错误。 https://react-dropzone-uploader.js.org/docs/examples#initial-file-from-data-url
const url = 'data:image/png;base64,.....';
fetch(url)
.then(res => res.blob())
.then(blob => {
const file = new File([blob], "File name");
this.setState({
photo: file
})
});
我的Dropzone
html
<DropzoneArea
style={{height: '30px'}}
maxFileSize={5000000}
filesLimit={3}
disabled = {this.state.fromSnaps}
onChange={this.handlePhotoChange}
dropzoneText={"Drag and drop the profile image here or click"}
acceptedFiles={['image/jpeg', 'image/png', 'image/bmp']}
dropzoneClass={classes.dropZoneCustomClass}
initialFiles={[this.state.photo]}
/>
感谢任何输入来解决此问题。
谢谢