Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 2.04 KB

README.md

File metadata and controls

74 lines (51 loc) · 2.04 KB

React File Base64

React Component for Converting Files to base64. It's based on Dev Mozilla Website

DEMO

Important

This package is a fork from Naufal Rabbani's original package. It seems like he's not maintaining it, and hence, this package was created instead so that other users could use it, as it seems the feature is highly requested. All credit for the core and base logic goes to him. All I did was correctly fix the code so that it would work correctly when importing as per noted in issue here.

Install

You can import react-file-base64.js to your react component file like this and process it with your preprocessor.

You can install it via NPM

npm install react-filebase64

Usage

import React from 'react';
import ReactDOM from 'react-dom';

import FileBase64 from 'react-filebase64';

class App extends React.Component {

  constructor() {
    super()
    this.state = {
      files: []
    }
  }

  // Callback~
  getFiles(files){
    this.setState({ files: files })
  }

  render() {
    return (
      <FileBase64
        multiple={ true }
        onDone={ this.getFiles.bind(this) } />
    )
  }

}


ReactDOM.render(<App />, document.getElementById("app"))

Props

multiple (Boolean)

Is your component support multiple file?

onDone (Function)

Callback Function When all files have been proceed

Thank You for Making this useful~

Let's talk about some projects with me

Just Contact Me At:

License

MIT Copyright (c) 2016 - forever Naufal Rabbani