source: frontend/src/Components/ImageUpload/ImageUpload.js@ 0f5aa27

Last change on this file since 0f5aa27 was e6c2521, checked in by darsov2 <62809499+darsov2@…>, 10 months ago

images upload/download impl, other fixes

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import React, { useState } from "react";
2import { Button, Container, FormControl, FormGroup, FormLabel, Image } from "react-bootstrap";
3import useFileChange from "../Hooks/FilesUpload/useFileChange";
4
5const ImageUpload = () => {
6 const { onFileChangeHandler } = useFileChange();
7 const [selectedFiles, setSelectedFiles] = useState([]);
8
9 return (
10 <Container>
11 <FormGroup className="mb-3">
12 <FormLabel>Upload Images:</FormLabel>
13 <FormControl
14 type="file"
15 multiple
16 onChange={(e) => setSelectedFiles(Array.from(e.target.files))}
17 />
18 </FormGroup>
19 <Button onClick={() => onFileChangeHandler(selectedFiles)}>
20 Upload Files
21 </Button>
22 <Container>
23 {selectedFiles.map((file, index) => (
24 <Image
25 key={index}
26 onClick={() => {}}
27 fluid
28 src={URL.createObjectURL(file)}
29 alt={`Uploaded Image ${index + 1}`}
30 />
31 ))}
32 </Container>
33 </Container>
34 );
35};
36
37export default ImageUpload;
Note: See TracBrowser for help on using the repository browser.