Skip to content

fix:complete the function of 'accept' option#455

Open
Coloey wants to merge 1 commit intoreact-component:masterfrom
Coloey:master
Open

fix:complete the function of 'accept' option#455
Coloey wants to merge 1 commit intoreact-component:masterfrom
Coloey:master

Conversation

@Coloey
Copy link

@Coloey Coloey commented Oct 17, 2022

const uploaderProps = {
  action: '/upload.do',
  data: { a: 1, b: 2 },
  multiple: true,
  beforeUpload(file) {
    console.log('beforeUpload', file.name);
  },
  onStart: file => {
    console.log('onStart', file.name);
  },
  onSuccess(file) {
    console.log('onSuccess', file);
  },
  onProgress(step, file) {
    console.log('onProgress', Math.round(step.percent), file.name);
  },
  onError(err) {
    console.log('onError', err);
  },
  capture: 'user',
  accept:'.jpg',
  directory: false
};

when I try to upload pictures in .jpg format, pictures in .png format can also be uploaded,and I try to solve this problem,here is my programme

 onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const { accept, directory } = this.props;
    const { files } = e.target;
    const acceptedFiles = [...files].filter(
      (file: RcFile) => !directory && attrAccept(file, accept),
    );
    this.uploadFiles(acceptedFiles);
    this.reset();
  };

@vercel
Copy link

vercel bot commented Oct 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
upload ✅ Ready (Inspect) Visit Preview Oct 17, 2022 at 2:09PM (UTC)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant