Search code examples
phpsrc

How to get normal src of an coded image like this in php?


Hi there I works with simple php parser to save imgs form external server...So I want to get an normal src of an picture but it seem below img elements has an unusuall src ...

Is there anyway to turn this code to normal src or at least first save it in my server?

Note: text in src is too long...more than 170000 chars...I removed most of them to insert here to show you...

<img style="display: block; margin-left: auto; margin-right: auto;" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAZAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAgICAgICAgICAwMDAwMDAwMDAwEBAQEBAQECAQECAgIBAgIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD/8AAEQgBZQJ2AwERAAIRAQMRAf/EANcAAAAFBQEAAAAAAAAAAAAAAAIDBAgJAQUGBwoAAQAABgMBAQAAAAAAAAAAAAACAwQFBgcAAQgJChAAAQMCBAQEAwUFBQQFCQQLAQIDBBEFACESBjFBEwdRYSIIcRQJgZGhMhWxwdFCI/DhUjMW8WJyJJKistIXgkNTdLQldTcYwo1J+AH8U2v8uqLpH6v5jprx0gEfAaySD8RiOkWfmihfp9w/igf0u9f//Z" alt="">

Solution

  • Copy all of the src text after base64, and use php's base64_decode function to decode it. Once there you can write it to a jpg file if you want.