PHP code example of starrysea / uimages

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

    

starrysea / uimages example snippets


// routes/web.php

Route::post('/img','ImagesGatherTest@upload');

Route::get('/img/{base64}','ImagesGatherTest@getPicture');

use Starrysea\Uimages\Images;

class ImagesGatherTest extends Images
{
    // open privacy mode
    protected $secret = true;

    // allow all domain cross-domain
    protected function crossDomainWhitelist()
    {
        return '*'; // all domain can access
    }

    // set secret picture access address
    protected function secretUrl()
    {
        return 'https://xingyue.test/img';
        // https:/xingyue.test/img/aW1hZ2VzL3
    }

    // set picture storage directory
    protected function storage()
    {
        return 'user/avatar';
    }

    // allow upload picture format
    protected function accept()
    {
        return ['png']; // only upload png picture
    }

    // success callback
    protected function call_success($filed, string $url, string $path)
    {
        dump('success', $url, $path);
    }

    // error callback
    protected function call_error(string $message, $data = '')
    {
        dump('error', $message, $data);
    }
}