PHP code example of aquinoaldair / storage-image

1. Go to this page and download the library: Download aquinoaldair/storage-image 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/ */

    

aquinoaldair / storage-image example snippets


use AquinoAldair\StorageImage\StorageImage;

$image = "data:image/png;base64.....";

//store image with random 20 character name in Storage disk public (storage/app/public/customFolder) 
$file_name = StorageImage::FromBase64($image)->store("custom_folder");

echo $file_name; // "custom_folder/jqmix7a1l6masdGasd7S.jpg"

$image = request()->image;

$file_name = StorageImage::FromFormData($image)->store("custom_folder");

$url = "https://homepages.cae.wisc.edu/~ece533/images/airplane.png";

$file_name = StorageImage::FromURL($url)->store("custom_folder");

$url = "https://homepages.cae.wisc.edu/~ece533/images/airplane.png";

$file_name = StorageImage::FromString($url)->store("custom_folder");

echo $file_name; // "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"





namespace AquinoAldair\StorageImage\Strategies;

use AquinoAldair\StorageImage\Contract\Image;

class MyCustomClass implements Image
{
     protected $file;
     
     public function __construct($file)
     {
         $this->file = $file;
     }
    public function store($folder = null)
    {
        // do something
    }
}
$image = "something";

StorageImage::make(new MyCustomClass($image))->store("custom_folder");