wuyumin/file2base64 is a Laravel package for file to base64..
It currently has 2 GitHub stars and 900 downloads on Packagist (latest version v0.3.0).
Install it with composer require wuyumin/file2base64.
Discover more Laravel packages by wuyumin
or browse all Laravel packages to compare alternatives.
Last updated
base64 files are used for embedding in web pages.
install in Composer
composer require wuyumin/file2base64
php code
require __DIR__ . '/../vendor/autoload.php';
use File2base64\File2base64;
$file2base64 = new File2base64();
# $file2base64 = new File2base64(['bmp' => 'image/bmp']);
$file2base64->toFile('file2base64.png', 'file2base64.txt');
# echo $file2base64->toBase64('file2base64.png');
(tips:Laravel 5.5+ can ignore step 2、3,version 5.5+ support to register automatically)
Composer install composer require wuyumin/file2base64
(ServiceProvider)add the follow line to the section providers of config/app.php
File2base64\Laravel\ServiceProvider::class,
(Facades)add the follow line to the section aliases of config/app.php(optional)
'File2base64' => File2base64\Laravel\Facade::class,
base64 file string
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
html code
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="">
web page demo: All in one page with base64 audio,no web link with audio file
.png、.jpg、.jpeg、.gif、.ico、.mp3、.ogg
You can init for other type use array.
$file2base64 = new File2base64(['bmp' => 'image/bmp']);