본문 바로가기
기타 프로그램

[PHP] 이미지 파일 base64 인코딩하기

by 고체물리학 2022. 8. 25.

$path = '/Users/user/Downloads/test.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);

 

결과

 

 

반응형

댓글