PHP code example of awaisjameel / base64filehandler

1. Go to this page and download the library: Download awaisjameel/base64filehandler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

awaisjameel / base64filehandler example snippets


use AwaisJameel\Base64FileHandler\Facades\Base64FileHandler;

// Store a base64 encoded file
$filePath = Base64FileHandler::store($base64Data);

// Store with custom parameters
$filePath = Base64FileHandler::store(
    $base64Data,
    'local',                   // custom disk
    'custom/path/',            // custom path
    'original-filename.jpg',   // original filename
    ['jpg', 'png']             // allowed extensions
);

use AwaisJameel\Base64FileHandler\Facades\Base64FileHandler;

try {
    Base64FileHandler::isValidImage($base64Data);
    // The data is a valid image
} catch (Exception $e) {
    // The data is not a valid image
}

use AwaisJameel\Base64FileHandler\Facades\Base64FileHandler;

$fileInfo = Base64FileHandler::getFileInfo($base64Data);
// Returns array with mime, extension, size, and decoded data

use AwaisJameel\Base64FileHandler\Base64FileHandler;

$handler = new Base64FileHandler([
    'disk' => 'local',
    'path' => 'custom/path/',
    'allowed_extensions' => ['jpg', 'png', 'pdf'],
]);

$filePath = $handler->store($base64Data);
bash
php artisan vendor:publish --provider="AwaisJameel\Base64FileHandler\Base64FileHandlerServiceProvider" --tag="config"