[Laravel] convert base64 string to image save

[Laravel] convert base64 string to image save

728x90

반응형

PHP 에서 base64_decode라는 함수를 제공 하고 있다.

위와 같이 간편하게 사용 할 수 있다.

다음은 라라벨에서 base64 string을 디코딩하여 이미지로 저장하는 방법이다.

//$file에 base64string 디코딩값을 넣음. $file = base64_decode(base64string); //파일명 지정. $safeName = 'test.bmp'; //file_put_contents함수를 이용하여 public경로로 저장해준다. $success = file_put_contents(public_path('/assets/').$safeName, $file);

아주 간편하다.

도움이 되셨다면 하트 및 댓글 부탁드립니다♥

728x90

반응형

from http://wondongho.tistory.com/178 by ccl(A) rewrite - 2021-01-05 15:25:55