Man*_*mal 5 reactjs material-ui dropdown
我正在尝试将初始图像加载到材质 ui dropzone。我有 base64 格式的图像,我想将它们作为初始文件加载到放置区。
我尝试使用 intialFiles 选项按照以下 url 来实现这一点。但仍然没有运气,也没有出现任何错误。 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
})
});
Run Code Online (Sandbox Code Playgroud)
我的空投区
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]}
/>
Run Code Online (Sandbox Code Playgroud)
感谢任何输入来解决这个问题。
谢谢