Commit 5b1e9608 authored by 王苓芝's avatar 王苓芝

文件格式限制

parent fcb238bd
import { Upload, Icon, Modal } from 'antd';
import { Upload, Icon, Modal, notification } from 'antd';
import React from 'react';
import config from '../../../config/env.config';
import { qiniuToken } from '@/services/qiniu';
......@@ -42,6 +42,16 @@ class PicturesWall extends React.Component {
});
};
beforeUpload = file => {
console.log('files', file);
const types = ['application/pdf', 'image/png', 'image/jpeg'];
if (types.indexOf(file.type) === -1) {
notification.error('输入格式有问题');
return false;
}
return true;
};
handleChange = ({ fileList }) => {
this.setState({ fileList });
};
......@@ -90,12 +100,12 @@ class PicturesWall extends React.Component {
return (
<div className="clearfix">
<Upload
accept="image/png, image/jpeg, .pdf"
customRequest={this.customRequest}
listType="picture-card"
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