diff --git a/src/App.jsx b/src/App.jsx index 3f8a3217d..1e26baf40 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -273,7 +273,10 @@ function App() { )} - setOpenNewUpload(false)}> + setOpenNewUpload(false)} + > New Upload {!loadingPosts && @@ -317,8 +320,7 @@ function App() { onChange={(e) => setPassword(e.target.value)} /> - - + { + let images = []; + if (e.target.files?.length) { setImage(Array.from(e.target.files)); + setImagePreviews(image); + } + for (let i = 0; i < e.target.files.length; i++) { + images.push(URL.createObjectURL(e.target.files[i])); } - }; + setImagePreviews(images); + }; const { enqueueSnackbar } = useSnackbar(); @@ -121,7 +131,21 @@ function ImgUpload(props) { ref={imgInput} disabled={uploadingPost} /> - )} + )} + {imagePreviews && ( +
+ {imagePreviews.map((img, i) => { + return ( + {`image-${i}`} + ); + })} +
+ )} setCaption(e.target.value)} value={caption} @@ -131,7 +155,7 @@ function ImgUpload(props) { rows={4} disabled={uploadingPost} /> - + Upload diff --git a/src/components/imgPreview.css b/src/components/imgPreview.css new file mode 100644 index 000000000..d9efac437 --- /dev/null +++ b/src/components/imgPreview.css @@ -0,0 +1,5 @@ +.preview{ + width: 150px; + height: auto; + padding: 50px; + } \ No newline at end of file diff --git a/src/index.css b/src/index.css index 07d726c60..82421709f 100644 --- a/src/index.css +++ b/src/index.css @@ -210,3 +210,5 @@ div#picker { left: -7px; transform: scale(0.9); } + +