This repository was archived by the owner on Oct 8, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ npm install react-file-reader --save
1414```
1515
1616## ChangeLog
17+ - 1.0.4
18+ - adds the ability to return both base64 strings and an HTML5 FileList from handleFiles
1719 - 1.0.3
1820 - bumps React version to 15.5 and fixes UNMET peer dependency with webpack
1921 - 1.0.2
@@ -85,5 +87,18 @@ handleFiles = files => {
8587 "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA..."
8688```
8789
90+ ### Both Base64 and HTML5 FileList
91+ ``` javascript
92+ handleFiles = (base64Files , fileList ) => {
93+ console .log (base64Files);
94+ console .log (fileList);
95+ }
96+
97+ < ReactFileReader base64= {true } multipleFiles= {true } handleFiles= {this .handleFiles }>
98+ < button className= ' btn' > Upload< / button>
99+ < / ReactFileReader>
100+ ```
101+ When ` base64={true} ` , ` handleFiles ` will return both the Base64 string and the HTML5 FileList object.
102+
88103## Copyright
89104Copyright (c)2017 [ Grillwork Inc] ( http://grillwork.io ) . See [ LICENSE] ( https://github.com/GrillWork/react-file-reader/blob/master/LICENSE ) for details.
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ export default class ReactFileReader extends React.Component {
3535 files . push ( reader . result )
3636
3737 if ( files . length === ef . length ) {
38- this . props . handleFiles ( files ) ;
38+ this . props . handleFiles ( files , ef ) ;
3939 }
4040 }
4141
@@ -46,7 +46,7 @@ export default class ReactFileReader extends React.Component {
4646 let reader = new FileReader ( ) ;
4747
4848 reader . onloadend = function ( e ) {
49- this . props . handleFiles ( reader . result )
49+ this . props . handleFiles ( reader . result , ef )
5050 } . bind ( this )
5151
5252 reader . readAsDataURL ( f )
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ var ReactFileReader = function (_React$Component) {
6969 files . push ( reader . result ) ;
7070
7171 if ( files . length === ef . length ) {
72- _this . props . handleFiles ( files ) ;
72+ _this . props . handleFiles ( files , ef ) ;
7373 }
7474 } ;
7575
@@ -85,7 +85,7 @@ var ReactFileReader = function (_React$Component) {
8585 var _reader = new FileReader ( ) ;
8686
8787 _reader . onloadend = function ( e ) {
88- this . props . handleFiles ( _reader . result ) ;
88+ this . props . handleFiles ( _reader . result , ef ) ;
8989 } . bind ( _this ) ;
9090
9191 _reader . readAsDataURL ( f ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " react-file-reader" ,
3- "version" : " 1.0.3 " ,
3+ "version" : " 1.1.0 " ,
44 "description" : " A flexible ReactJS component for handling styled HTML file inputs." ,
55 "main" : " index.js" ,
66 "repository" :
" [email protected] :GrillWork/react-file-reader.git" ,
You can’t perform that action at this time.
0 commit comments