Home > Article > Development Tools > [composer package] free-pic free picture bed
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!
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)
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!