How to convert PDF file to Base64 encode using PHP?

Use this three PHP function to convert encode pdf file to base64.

base64_encode

file_get_contents

chunk_split

Example :

$encode = chunk_split(base64_encode(file_get_contents("Path to the pdf file")));

base64_encode takes a string as an input, so grab the content of the file using file_get_contents and pass it to the base64_encode.

Demo

Happy Coding 🙂

Mobio solutions

Leave a Reply

Your email address will not be published. Required fields are marked *