[React] 파일 업로드 관리하기

2022. 7. 4. 11:13·Stack/React

업로드 이미지를 관리하는 스토리지 서버 "multer"

터미널 열고 ~ npm install multer

 

const multer = require('multer');

const upload = multer({ dest: 'upload/' })

 

이미지 파일을 post로 요청이 왔을 때 업로드라는 폴더에 이미지를 저장

app.post("/image', upload.single('image'), (req, res) => {

                const file = req.file;

                res.send({

                                imageUrl: file.path

                })

})

 

API 서버

데이터베이스 (sqlite)

스토리지 서버 (multer)

'Stack > React' 카테고리의 다른 글

[React] Lamp 쇼핑몰 구현하기 6 (삭제기능 / carousel 구현)  (0) 2022.07.04
[React] Lamp 쇼핑몰 구현하기 5 (이미지 업로드 / 상품등록 기능 구현)  (0) 2022.07.04
[React] 상태관리(useState / useReducer) 복습  (0) 2022.07.04
[React] npm start 오류(throw err;) 해결하기  (0) 2022.07.01
[React] Lamp 쇼핑몰 구현하기 4 (Sqlite 연동)  (0) 2022.07.01
'Stack/React' 카테고리의 다른 글
  • [React] Lamp 쇼핑몰 구현하기 6 (삭제기능 / carousel 구현)
  • [React] Lamp 쇼핑몰 구현하기 5 (이미지 업로드 / 상품등록 기능 구현)
  • [React] 상태관리(useState / useReducer) 복습
  • [React] npm start 오류(throw err;) 해결하기
7ingout
7ingout
  • 7ingout
    Hello, 7ingout world!
    7ingout
  • 전체
    오늘
    어제
    • 분류 전체보기 (205)
      • Project (5)
      • Stack (173)
        • React (40)
        • JavaScript (50)
        • TypeScript (14)
        • HTML (11)
        • CSS (31)
        • Spring (9)
        • PHP (15)
        • SQL (3)
        • Python (0)
      • ETC (9)
      • Design (13)
        • Illustrator (6)
        • Photoshop (7)
      • Articloid (4)
        • 7ingout (4)
  • 공지사항

    • ☻
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
7ingout
[React] 파일 업로드 관리하기
상단으로

티스토리툴바