0.0.26 • Published 6 years ago
react-file-uploader1 v0.0.26
react-file-uploader
Simple React component to upload files with image cropper.
Installation
npm install --save react-file-uploader
or:
yarn add react-file-uploader
Usage
React-file-uploader is using React portals to display modal with file cropper. You need to create DOM node in the root of your project:
<div id="uploader-modal"></div>
Import ReactFileUploader component:
import ReactFileUploader from 'react-file-uploader';
function MyFileUploader() {
return (
<ReactFileUploader handleUploadFile={uploadFile} />
);
}
Props
prop | type | default | description |
---|---|---|---|
accept | string | null | (optional) Types of files that uploader should accept |
children | renderable | null | (optional) Custom upload file input label |
customLoader | renderable | null | (optional) Custom loader |
handleUploadFile | function | null | (required) Callback function uploading file to database |
label | string | Click to upload file | (optional) Custom label for default upload file button |
style | object | {} | (optional) Style object with 'uploadButtonStyle' key to override upload button in modal styles |
uploadButtonLabel | string | Upload file | (optional) Custom label for upload button in modal |
handleUploadFile example
const uploadFile = async(file, fileType) => {
const formdata = new FormData();
formdata.append('file', file);
const options = {
method: 'POST',
formdata,
headers: { Accept: 'application/json' },
...configToken,
};
try {
await fetch(url, options);
} catch(e) {
showNotification(e);
}
}
License
MIT
0.0.26
6 years ago
0.0.25
6 years ago
0.0.24
6 years ago
0.0.23
6 years ago
0.0.22
6 years ago
0.0.21
6 years ago
0.0.20
6 years ago
0.0.19
6 years ago
0.0.18
6 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago