0

I am using Upload component in Ant Design to upload files but I have a problem with upload manually. I want to replace the <Button /> upload by auto trigger start uploading if the file was selected from <Upload />

  return (
    <div style={{ padding: '20px' }}>
      <Upload {...props}>
        <Button icon={<UploadOutlined />}>
          Select File
        </Button>
      </Upload>

      // The button upload below not needed for me, so i need to remove it, 
      however I need <Upload /> also works without this Button

      <Button
        type="primary"
        onClick={handleUpload}
        disabled={fileList.length === 0}
        loading={uploading}
        style={{ marginTop: 16 }}
      >
        {uploading ? 'Uploading' : 'Start Upload'}
      </Button>
    </div>
  );

Here's my full code on Stackblitz: https://stackblitz.com/edit/react-w1pc9r?file=src/App.js

A Little Girl
  • 303
  • 3
  • 4
  • 12
  • https://stackoverflow.com/a/51519603/13847690 Maybe this answer would help you in your question – Subrato Pattanaik Feb 08 '22 at 08:01
  • @SubratoPattanaik thanks for your suggesting. But it not my expected. I need to trigger upload when user was selected files from browser without pressed button upload – A Little Girl Feb 08 '22 at 09:18
  • autoloading is the default behavior. your code is just an example from the documentation. try to take another example from [there](https://ant.design/components/upload/#components-upload-demo-upload-manually) – Andrey Feb 14 '22 at 09:36

0 Answers0