Home  >  Article  >  Development Tools  >  [composer package] free-pic free picture bed

[composer package] free-pic free picture bed

藏色散人
藏色散人forward
2020-11-02 13:47:242676browse

The following tutorial column of composer will introduce to you about [composer package] free-pic free picture bed, I hope it will be helpful to friends in need!

free-pic Free Picture Bed

Experience demo(http://free-pic.hzz.cool/upload.html)

github address (https://github.com/hezhizheng/free-pic)

packagist address (https://packagist.org/packages/ hzz/free-pic)

feature

  • 三无图 beds (No storage limit | No need to upload credentials | No origin cross-domain detection )
  • Supports using proxy, easy to use, easy to expand
  • Supports "gif", "jpeg", "jpg", "png" image formats

support image bed

  • https://sm.ms/
  • https://imgkr.com/
  • https:// imgbb.com/upload
  • ...If you find other three-no-picture beds, then expand them

##Use

to download and install

composer require "hzz/free-pic @dev"
Upload pictures to local

...
use Hzz\File;

// 上传图片到本地 , 也可使用其他上传类,最终获取图片的绝对路径即可
$fileEntity = File::singleton();
// $field_name 上传图片的字段名称 默认 file
// $dir 指定上传路径 默认 ''
$filepath = $fileEntity->upload($field_name,$dir);

Upload pictures to third-party picture bed

// 通过不同类型初始化实现类
// 支持参数类型(img_kr、sm、img_bb)
$serve = FreePic::create('img_kr'); 
// $serve->proxy = 'http://127.0.0.1:58591'; // 按需设置代理、sm.ms在移动网络下可能需要fq
$url = $serve->upload($filepath);

Delete local pictures

$fileEntity->delete($filepath);
For detailed usage, please refer to tests use case

The above is the detailed content of [composer package] free-pic free picture bed. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete