1.0.9 • Published 5 years ago

react-browse-files v1.0.9

Weekly downloads
55
License
ISC
Repository
github
Last release
5 years ago

react-browse-files

A small component for building file upload fields of any type, for example a simple file upload button or an image gallery field with drag and drop support and preview of selected images.

Install

npm install --save react-browse-files

Or if you prefer yarn:

yarn add react-browse-files

Quick Example:

Create a simple upload button that accepts multiple PDF files (max 2MB per file / max 10MB for the whole selection).

import BrowseFiles from "react-browse-files";
<BrowseFiles
    multiple={true} 
    maxSize="2mb"
    multipleMaxSize="10mb"
    accept={["application/pdf","image/jpg","image/jpeg"]}
    onSuccess={files => this.setState({ files })}
    onError={errors => this.setState({ errors })}
>
    {({ browseFiles }) => (
        <>
            <button onClick={browseFiles}>Upload PDF</button>
            <ol>
                {this.state.files.map(file => (
                    <li key={file.name}>{file.name}</li>
                ))}
                {this.state.errors.map(error => (
                    <li key={error.file.name}>
                        {error.file.name} - {error.type}
                    </li>
                ))}
            </ol>
        </>
    )}
</BrowseFiles>

More examples on https://react-browse-files.netlify.com.

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago