Commit 479dad72 authored by 王苓芝's avatar 王苓芝

上传文件格式

parent 71be248b
......@@ -42,18 +42,12 @@ class PicturesWall extends React.Component {
});
};
beforeUpload = file => {
console.log('info', file);
const types = ['application/pdf', 'image/png', 'image/jpeg'];
if (types.indexOf(file.type) === -1) {
message.error('输入格式有问题');
}
return types.indexOf(file.type) === -1;
};
handleChange = info => {
console.log('info-handleChange', info.fileList);
const lastFile = (info.fileList.length && info.fileList[info.fileList.length - 1]) || [];
const types = ['application/pdf', 'image/png', 'image/jpeg'];
if (lastFile && types.indexOf(lastFile.type) === -1) {
message.error('文件格式错误!');
}
const fileList = info.fileList.filter(item => types.indexOf(item.type) !== -1);
this.setState({ fileList });
};
......@@ -108,7 +102,6 @@ class PicturesWall extends React.Component {
fileList={fileList}
onPreview={this.handlePreview}
onChange={this.handleChange}
beforeUpload={this.beforeUpload}
{...this.props}
>
{max && fileList.length >= max ? null : uploadButton}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment