@zhifez/react-file-uploader
A customised file uploader component for making your life easier with file upload in a React project.
Last updated 3 months ago by zhifez .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @zhifez/react-file-uploader 
SYNC missed versions from official npm registry.

react-file-uploader

A customised file uploader component for making your life easier with file upload in a React project.

Installation

Add react-file-uploader to your project by executing npm install @zhifez/react-file-uploader or yarn add @zhifez/react-file-uploader.

Usage

import React, { useState } from 'react';

import './App.css';
import { FileUploadButton } from './components/react-file-uploader/react-file-uploader';

const App = () => {
  let [ files, onUploadFiles ] = useState ( [] );
  let [ uploadError, onUploadError ] = useState ( null );

  return (
    <div>
      <FileUploadButton 
        label="Upload PDF file (Max size: 5MB)"
        maxSizeMB={5}
        onChange={onUploadFiles}
        onError={onUploadError}
        accept={'.pdf'}
        multiple={true}
      />
      {uploadError && 
      <p>{uploadError}</p>}
      <br />
      {files && files.map ( ( file, index ) => {
        return ( 
          <p key={index}>File {index} - {file.name}</p>
        );
      } )}
    </div>
  );
}

export default App;

Props

File Uploader

Name Type Default Required
inputRef ref null -
accept string .png, .jpeg, .gif, .jpg true
multiple bool false -
maxSizeMB number null -
onChange func null true
onError func null -
isHidden bool true -

File Upload Button

Name Type Default Required
className string/object .fileUploaderButton -
style object null -
label object Upload File -

Current Tags

  • 1.0.7                                ...           latest (3 months ago)

8 Versions

  • 1.0.7                                ...           3 months ago
  • 1.0.6                                ...           3 months ago
  • 1.0.5                                ...           3 months ago
  • 1.0.4                                ...           3 months ago
  • 1.0.3                                ...           4 months ago
  • 1.0.2                                ...           5 months ago
  • 1.0.1                                ...           5 months ago
  • 1.0.0                                ...           5 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |