import { useState } from "react";
export default function ImageUploadPreViewPage() {
const [imageUrl, setImageUrl] = useState("");
function onChangeFile(e) {
const myFile = e.target.files[0];
console.log(myFile);
const fileReader = new FileReader();
fileReader.readAsDataURL(myFile);
fileReader.onload = (data) => {
console.log(data.target.result);
setImageUrl(data.target.result);
};
}
return (
<div>
<input type="file" onChange={onChangeFile} />
<img src={imageUrl} alt="이미지출력창" width="100%" height="100%" />
</div>
);
}
프론트에서 올릴땐 PromiseAll 이 제일 빠르다
lazyNode
dropzone
dropzonedocs
avatar-editor
beautiful-dnd - 이미지 뿐만아니라 컴포넌트도 드래그해서 위치 조정할수 있다.