{"id":13543992,"url":"https://github.com/aleksei0807/react-images-uploader","last_synced_at":"2025-04-05T13:09:44.503Z","repository":{"id":51775112,"uuid":"76204534","full_name":"aleksei0807/react-images-uploader","owner":"aleksei0807","description":"React.js component for uploading images to the server","archived":false,"fork":false,"pushed_at":"2023-01-11T22:28:59.000Z","size":5728,"stargazers_count":177,"open_issues_count":31,"forks_count":63,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T11:05:38.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aleksei0807.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-11T22:40:17.000Z","updated_at":"2024-06-25T22:46:17.000Z","dependencies_parsed_at":"2023-02-09T08:46:42.385Z","dependency_job_id":null,"html_url":"https://github.com/aleksei0807/react-images-uploader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksei0807%2Freact-images-uploader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksei0807%2Freact-images-uploader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksei0807%2Freact-images-uploader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksei0807%2Freact-images-uploader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleksei0807","download_url":"https://codeload.github.com/aleksei0807/react-images-uploader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339158,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T11:00:40.270Z","updated_at":"2025-04-05T13:09:44.262Z","avatar_url":"https://github.com/aleksei0807.png","language":"JavaScript","funding_links":[],"categories":["UI Components","Demos","\u003csummary\u003eUI Components\u003c/summary\u003e"],"sub_categories":["Form Components"],"readme":"# React Images Uploader\n\n[![NPM](https://nodei.co/npm/react-images-uploader.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/react-images-uploader/)\n\nReact.js component for uploading images to the server\n\n![Demo](https://cdn.rawgit.com/aleksei0807/react-images-uploader/master/examples/demo.gif \"Demo\")\n\n## Examples\n\n### Example for multiple images:\n\n```javascript\nimport React, { Component } from 'react';\nimport ImagesUploader from 'react-images-uploader';\nimport 'react-images-uploader/styles.css';\nimport 'react-images-uploader/font.css';\n\nexport default class MyUploader extends Component {\n\trender() {\n\t\treturn (\n\t\t\t\u003cImagesUploader\n\t\t\t\turl=\"http://localhost:9090/multiple\"\n\t\t\t\toptimisticPreviews\n\t\t\t\tonLoadEnd={(err) =\u003e {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tlabel=\"Upload multiple images\"\n\t\t\t\t/\u003e\n\t\t);\n\t}\n}\n```\n\n### Example for one picture:\n\n```javascript\nimport React, { Component } from 'react';\nimport ImagesUploader from 'react-images-uploader';\nimport 'react-images-uploader/styles.css';\nimport 'react-images-uploader/font.css';\n\nexport default class MyUploader extends Component {\n\trender() {\n\t\treturn (\n\t\t\t\u003cImagesUploader\n\t\t\t\turl=\"http://localhost:9090/notmultiple\"\n\t\t\t\toptimisticPreviews\n\t\t\t\tmultiple={false}\n\t\t\t\tonLoadEnd={(err) =\u003e {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\tconsole.error(err);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tlabel=\"Upload a picture\"\n\t\t\t\t/\u003e\n\t\t);\n\t}\n}\n```\n\n### Example server (Node.js, Express)\n\nyou need to install cors-prefetch-middleware and images-upload-middleware from npm.\n\n```javascript\nimport express from 'express';\nimport corsPrefetch from 'cors-prefetch-middleware';\nimport imagesUpload from 'images-upload-middleware';\n\nconst app = express();\n\napp.use('/static', express.static('./server/static'));\n\napp.use(corsPrefetch);\n\napp.post('/multiple', imagesUpload(\n\t'./server/static/multipleFiles',\n\t'http://localhost:9090/static/multipleFiles',\n\ttrue\n));\n\napp.post('/notmultiple', imagesUpload(\n\t'./server/static/files',\n\t'http://localhost:9090/static/files'\n));\n\napp.listen(9090, () =\u003e {\n\tconsole.log('Listen: 9090');\n});\n```\n\n## Other servers\n\n- [Server on Go](https://github.com/aleksei0807/imagesServer)\n- [Server on Clojure](https://github.com/aleksei0807/clojure-images-server)\n\n## Props\n\n- `url: string` - server url;\n- `classNamespace: string` - namespace for all classNames (`default: 'iu-'`);\n- `inputId: string` - id and name for hidden input type file. Used for htmlFor in label (`default: 'filesInput'`);\n- `label: string` - label text;\n- `images: Array` - an array of references to the already uploaded images;\n- `disabled: boolean`;\n- `onLoadStart: function()` - callback, which is called when the download starts;\n- `onLoadEnd: function(error: { message: string, ... }, response?: JSON)`\n\n\tError messages:\n\t- `invalid response type` - additional params: response, fileName (imagesUploader);\n\t- `server error` - additional params: status (response status), fileName (imagesUploader);\n\t- `exceeded the number` - if there is `max` property and files count \u003e max;\n\t- `file type error` - additional params: type (file type), fileName (imagesUploader);\n\n- `deleteImage: function(key: number)` - callback which is called when the image has been deleted from the list;\n- `clickImage: function(key: number)` - callback which is called when the image preview is clicked;\n- `optimisticPreviews: boolean` - enables optimistic previews `default: false`;\n- `multiple: boolean` - allows to upload a bunch of images !`default: true`!;\n- `image: string` - this property works only when multiple: false! already loaded picture;\n- `notification: string` - this property works only with multiple: false! notification text;\n- `max: number` - the maximum number of pictures for a single upload;\n- `color: string` - color for text and svg `default: '#142434'`;\n- `disabledColor: string` - color for text and svg in disabled mode `default: '#bec3c7'`;\n- `borderColor: string` - border color `default: '#a9bac8'`;\n- `disabledBorderColor: string` - border color in disabled mode `default: '#bec3c7'`;\n- `notificationBgColor: string` - background color for notification `default: 'rgba(0, 0, 0, 0.3)'`;\n- `notificationColor: string` - text and svg color for notification `default: '#fafafa'`;\n- `deleteElement: string|element` - element for removing images;\n- `plusElement: string|element` - element for adding images;\n```\nclassNames: {\n\tcontainer: string,\n\tlabel: string,\n\tdeletePreview: string,\n\tloadContainer: string,\n\tdropzone: string,\n\tpseudobutton: string,\n\tpseudobuttonContent: string,\n\timgPreview: string,\n\tfileInput: string,\n\temptyPreview: string,\n\tfilesInputContainer: string,\n\tnotification: string,\n}\n```\n```\nstyles: {\n\tcontainer: Object,\n\tlabel: Object,\n\tdeletePreview: Object,\n\tloadContainer: Object,\n\tdropzone: Object,\n\tpseudobutton: Object,\n\tpseudobuttonContent: Object,\n\timgPreview: Object,\n\tfileInput: Object,\n\temptyPreview: Object,\n\tfilesInputContainer: Object,\n\tnotification: Object,\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksei0807%2Freact-images-uploader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleksei0807%2Freact-images-uploader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksei0807%2Freact-images-uploader/lists"}