Javascript - get extension from base64 image

后端 未结 8 1664

I have a base64 encoded image returned from a service and it looks like this:

/9j/4AAQSkZJRgABAQEASABIAAD/4Yp2aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWN         


        
8条回答
  •  無奈伤痛
    2021-01-01 10:31

    This one will work for any extension type: pdf, mp3, png, ....

    base64.substring(base64.indexOf('/') + 1, base64.indexOf(';base64'));

提交回复
热议问题