티스토리 뷰

개발지식/Laravel

Laravel 이미지 폴더

kimty1121 2024. 2. 7. 21:22

Laravel에서 이미지 파일을 관리할 때 어떠한 경로에 두면 좋은가?

 

두가지 경로를 알아본다.

 

1. public 폴더 밑에 image 폴더를 만들어 관리 (public/images)

- 여기에 두면 특별한 조치 없이 이미지를 읽을 수 있다.

 

2. storage/app/public 폴더에 관리

- 이 폴더내의 파일은 git ignore에서 관리 되기 때문에 github에 업로드 되지 않는다.

 

두 폴더 연결하기

php artisan storage:link 명령어 입력

The [/Users/kimtaeyoun/Desktop/Dev/udemy_Laravel_dev2/umarche/public/storage] link has been connected to [/Users/kimtaeyoun/Desktop/Dev/udemy_Laravel_dev2/umarche/storage/app/public].
The links have been created.

 

이와 같은 결과가 표시되면 연결이 된 것이다.

 

asset("images/logo.png") 같은 헬퍼 함수로 불러올 수 있다.