PHP code example of nomandia / iimage

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

    

nomandia / iimage example snippets


// 注意要引入命名空间
$image = new IImage();

$config = [
    'folder'      => 'avatar',
    'filePrefix' => 'avatar_',
    'maxWidth'   => 260,
];

// $file 是 Laravel 的 Illuminate\Http\UploadedFile 对象 ,可以通过 Request 直接得到

$file = $request->avatar;
// 也可以通过下面方式
$file = $request->file('avatar');

$info = $image->upload($file, $config);

// 也可以使用链式操作去配置
$info = $image->setConfig($config)->upload($file);

'upload_type'      => 'local',
// 改为
'upload_type'      => 'qiniu',
bash
php artisan vendor:publish --provider="Nomandia\IImage\IImageProvider"