guanguans/uploadfile

This package is abandoned and no longer maintained. No replacement package was suggested.

通用文件上传类

v1.3.3 2020-10-30 09:05 UTC

This package is auto-updated.

Last update: 2020-10-30 10:25:35 UTC


README

环境要求

  • PHP >= 5.4

安装

$ composer require guanguans/uploadfile -vvv

使用

<?php
use Guanguans\UploadFile;

$upload = new UploadFile();
$upload->maxSize       = 1*1024*1024;    // 默认为-1,不限制上传大小
$upload->savePath      = './upload/';    // 上传根目录
$upload->saveRule      = 'uniqid';       // 上传文件的文件名保存规则
$upload->uploadReplace = true;           // 如果存在同名文件是否进行覆盖
$upload->autoSub       = true;           // 上传子目录开启
$upload->subType       = 'date';         // 上传子目录命名规则
$upload->allowExts     = ['jpg', 'png']; // 允许类型

if ($upload->upload()) {
    $upload->getUploadFileInfo();
} else {
    $upload->getErrorMsg();
}

License

MIT