forked from Gitlink/forgeplus-react
上传文件
This commit is contained in:
parent
a3c6ad78ee
commit
feb6ad6d89
|
@ -61,6 +61,11 @@ class Index extends Component {
|
|||
handleChange = (info) => {
|
||||
const { changeIsComplete } = this.props;
|
||||
changeIsComplete && changeIsComplete(true);
|
||||
const file = info.file;
|
||||
if(file && !file.type){
|
||||
let flag = this.checkFile(file.name);
|
||||
if(!flag) return;
|
||||
}
|
||||
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
|
||||
let fileList = info.fileList;
|
||||
this.setState({ fileList: appendFileSizeToUploadFileAll(fileList) });
|
||||
|
@ -76,15 +81,22 @@ class Index extends Component {
|
|||
array && this.props.load && this.props.load(array);
|
||||
}
|
||||
|
||||
beforeUpload = (file) => {
|
||||
if(file && !file.type){
|
||||
let name = file.name;
|
||||
const filestr = ['.rar','.iso',".flv", ".rmvb", ".mmf", ".ape"];
|
||||
checkFile=(str)=>{
|
||||
const filestr = ['.rar','.iso',".flv", ".rmvb", ".mmf", ".ape", ".vsdx", ".msi",".md"];
|
||||
let flag = false;
|
||||
for(var i= 0;i<filestr.length;i++){
|
||||
let reg = new RegExp("(.+(?=["+filestr[i]+"]$))");
|
||||
flag = reg.test(name);
|
||||
flag = reg.test(str);
|
||||
if(flag){
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
beforeUpload = (file) => {
|
||||
if(file && !file.type){
|
||||
let flag = this.checkFile(file.name);
|
||||
if(!flag){
|
||||
this.props.showNotification(`暂不支持此格式文件的上传!`);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue