https://github.com/rouftom/react-mui-fileuploader
🗃️ React mui fileuploader is a react component based on @mui v5 that allows you to upload files with an awesome ui component
https://github.com/rouftom/react-mui-fileuploader
filepicker javascript mui reactjs
Last synced: about 1 month ago
JSON representation
🗃️ React mui fileuploader is a react component based on @mui v5 that allows you to upload files with an awesome ui component
- Host: GitHub
- URL: https://github.com/rouftom/react-mui-fileuploader
- Owner: rouftom
- License: mit
- Created: 2021-10-02T19:55:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-10T06:33:11.000Z (10 months ago)
- Last Synced: 2025-04-09T07:38:07.618Z (2 months ago)
- Topics: filepicker, javascript, mui, reactjs
- Language: TypeScript
- Homepage:
- Size: 275 KB
- Stars: 29
- Watchers: 1
- Forks: 21
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
🗃️ React Material Fileuploader
developed with @mui v5
![]()
![]()
![]()
![]()
---
React mui fileuploader is a React component based on @mui v5 that allows you to upload files with an awesome ui component.
## [DEMO](https://eb6ie7.csb.app/)
## 🚀 Installation
```nodejs
npm install react-mui-fileuploader
```## 💻 Usage
```javascript
const handleFileUploadError = (error) => {
// Do something...
}const handleFilesChange = (files) => {
// Do something...
setUploadedFiles([...files]);
}return (
{
// access to component context here
}}
ContainerProps={{
elevation: 0,
variant: "outlined",
sx: { p: 1 }
}}
PlaceholderImageDimension={{
xs: { width: 128, height: 128 },
sm: { width: 128, height: 128 },
md: { width: 164, height: 164 },
lg: { width: 256, height: 256 }
}}
/>
)
```## 🎨 Possible application
```javascript
import React, { useState } from "react"
import { createRoot } from "react-dom/client"
import FileUpload from "react-mui-fileuploader"function MuiFileUploader() {
const [filesToUpload, setFilesToUpload] = useState([])const handleFilesChange = (files) => {
// Update chosen files
setFilesToUpload([ ...files ])
};const uploadFiles = () => {
// Create a form and post it to server
let formData = new FormData()
filesToUpload.forEach((file) => formData.append("files", file))fetch("/file/upload", {
method: "POST",
body: formData
})
}return (
<>
{}}
/>
Upload
>
)
}const root = createRoot(document.getElementById("root"))
root.render()
```[](https://codesandbox.io/s/thirsty-visvesvaraya-r9u6ho?fontsize=14&hidenavigation=1&theme=dark)
## Data structure
| Name | Type | Required | Details |
|------ |--- |--- |--- |
| getBase64 | `boolean` | `false` | Get the original input files. Default value `false` |
| multiFile | `boolean` | `false` | Multifile support. Default value `true` |
| title | `string` | `false` | Component title |
| header | `string` | `false` | Banner component big title |
| showPlaceholderImage | `boolean` | `false` | Show or hide placeholder image |
| imageSrc | `string` | `false` | Banner image placeholder source path |
| imageSrcAlt | `string` | `false` | Banner image placeholder label |
| leftLabel | `string` | `false` | Banner left label |
| rightLabel | `string` | `false` | Banner right label |
| buttonLabel | `string` | `false` | Banner button label |
| buttonRemoveLabel | `string` | `false` | Remove button label |
| disabled | `boolean` | `false` | This property enables or disables the component. Default value `false` |
| maxFileSize | `number` | `false` | Maximum size (in mb) for files to add. Default value `0`. Value `0` means `unlimited size` |
| maxUploadFiles | `number` | `false` | Maximum files to add. Default to `0`. Value `0` means `unlimited size` |
| errorSizeMessage | `string` | `false` | Error returned when a file exceeds `maxFileSize` limit |
| acceptedType | `string` | `false` | Accepted file type. Default value `image/*` |
| allowedExtensions | `array` | `false` | Array of allowed extensions. For example, you can specify `['jpg', 'jpeg', 'png']`as allowedExtensions |
| filesContainerHeight | `number` | `false` | Container Height |
| maxFilesContainerHeight | `number` | `false` | Container max height. Default value `300` |
| onError | `function` | `false` | Returned error message when error occurs |
| onFilesChange | `function` | `false` | Event handler returned when files changes |
| onContextReady | `function` | `false` | Returns the component context api |
| BannerProps | `object` | `false` | Banner props. Only MUI props are accepted |
| ContainerProps | `object` | `false` | Container props. Only MUI props are accepted |
| PlaceholderImageDimension | `object` | `false` | Dimensions (width and height) of the placeholder image. You can specify them in the properties `xs: {width: 64, height: 64}`, `sm: {width: 64, height: 64}`, `md: {width: 64, height: 64}`, `lg: {width: 64, height: 64}`, etc. |
| PlaceholderGridProps | `object` | `false` | Customize the placeholder Grid `xs`, `sm`, `md`, `lg`, `xl` sizes |
| LabelsGridProps | `object` | `false` | Customize the labels Grid `xs`, `sm`, `md`, `lg`, `xl` sizes |## 😁 Authors
- Muller Roufaou ([rouftom](http://github.com/rouftom))
## 🤔 FAQ
* __Where can I find more documentation?__
This library is a marriage of [@mui](http://mui.com/getting-started/usage/) and a React setup created with [React](https://fr.reactjs.org/). Either one would be a great place to start!
## 🙇♂️ Extra
Do you like this library ? Buy me a coffee or support me with a star on Github
* Btc address: `bc1qettgagenn9nc8ks7ghntjfme96yvvkfhntk774`
* Eth address: `0xB0413d8D0336E263e289A915c383e152155881E0`
## License
### react-mui-fileuploader
MIT License
Copyright (c) 2023 rouftom
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.