PHPackages                             quansitech/qscmf-formitem-tengxun-cos - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. quansitech/qscmf-formitem-tengxun-cos

ActiveLibrary

quansitech/qscmf-formitem-tengxun-cos
=====================================

qscmf form item cos

v1.2.2(4y ago)064↓100%1MITJavaScriptPHP &gt;=7.2.0

Since Sep 21Pushed 4y ago2 watchersCompare

[ Source](https://github.com/quansitech/qscmf-formitem-tengxun-cos)[ Packagist](https://packagist.org/packages/quansitech/qscmf-formitem-tengxun-cos)[ RSS](/packages/quansitech-qscmf-formitem-tengxun-cos/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (8)Used By (0)

FormBuilder腾讯云cos上传组件
=====================

[](#formbuilder腾讯云cos上传组件)

用法
--

[](#用法)

### 1.安装及配置

[](#1安装及配置)

#### 1.1安装

[](#11安装)

```
composer require quansitech/qscmf-formitem-tengxun-cos
```

#### 1.2在env文件中加入

[](#12在env文件中加入)

```
COS_SECRETID=[腾讯云api secretid]
COS_SECRETKEY=[腾讯云api secretkey]
COS_HOST=[cos存储地址]
```

#### 1.3在config.php中对应的上传类型更改配置

[](#13在configphp中对应的上传类型更改配置)

示例

```
'UPLOAD_TYPE_IMAGE' => array(
    'mimes'    => 'image/jpeg,image/png,image/gif,image/bmp', //允许上传的文件MiMe类型
    'maxSize'  => 5*1024*1024, //上传的文件大小限制 (0-不做限制)
    'exts'     => 'jpg,gif,png,jpeg', //允许上传的文件后缀
    'autoSub'  => true, //自动子目录保存文件
    'subName'  => array('date','Ymd'), //子目录创建方式，[0]-函数名，[1]-参数，多个参数使用数组
    'rootPath' => './Uploads/', //保存根路径
    'savePath' => 'image/', //保存路径
    'saveName' => array('uniqid', ''), //上传文件命名规则，[0]-函数名，[1]-参数，多个参数使用数组
    'saveExt'  => '', //文件保存后缀，空则使用原后缀
    'replace'  => false, //存在同名是否覆盖
    'hash'     => true, //是否生成hash编码
    'callback' => false, //检测文件是否存在回调函数，如果存在返回文件信息数组
    'cos_host' => env('COS_HOST'),
),
```

### 2.使用

[](#2使用)

#### 上传

[](#上传)

```
$builder=new FormBuilder();
$builder
    ->addFormItem('picture_cos1','picture_cos','单图Cos1')
    ->addFormItem('pictures_cos1','pictures_cos','多图Cos1')
    ->addFormItem('file_cos1','file_cos','单文件Cos1')
    ->addFormItem('files_cos1','files_cos','多文件Cos1')
    ->display();
```

默认采用image和file类型上传，可通过定义data-url参数来设置需要的类型

#### 前端组件

[](#前端组件)

在页面加载js文件

```

```

用法:

```

        上传

        var opt = {
            value: [
                {
                    file_id: 36,
                    name: '测试.jpg',
                    thumbUrl: "https:\/\/demo.test\/61616c4957275_thumb.png",
                    file_url: "https:\/\/demo.test\/61616c4957275.png"
                }
            ],
            listType: 'text',
            policyUrl: 'http://demo.test/extends/TengxunCos/policyGet/type/image',
            maxCount: 1,
            showUploadList: false,
            onChange: function(files){ console.log(files); }
        };

        CosUploader(document.getElementById('upload'), opt);

```

配置项说明:

配置项类型说明默认值valuearray初始化fileList, file 的属性有 name 文件名称， file\_id 文件id, thumbUrl 缩略图, file\_url 文件的地址\[\]listTypestring[antd说明文档](https://ant.design/components/upload-cn/)picture-cardpolicyUrlstring获取cos上传策略地址/extends/TengxunCos/policyGet/type/imagemaxCountnumber[antd说明文档](https://ant.design/components/upload-cn/)1showUploadList[antd说明文档](https://ant.design/components/upload-cn/)[antd说明文档](https://ant.design/components/upload-cn/)trueonChangecallback文件上传完成触发change回调，返回当前文件列表，文件列表格式：\[{file\_id:1, file\_url:'url'}\]cropobject[antd-img-crop说明文档](https://github.com/nanxiaobei/antd-img-crop)false### 3.升级

[](#3升级)

#### 升级至1.1.0

[](#升级至110)

##### 获取文件url

[](#获取文件url)

```
/**
 * @var int $file_id file_pic_id
 * @var int $expire 过期时间
*/
$url=\FormItem\TengxunCos\TengxunCos::getInstance()->getFileUrl($file_id,$expire);
```

##### 支持私有读bucket

[](#支持私有读bucket)

在上传文件配置中加入 'security' =&gt; true,即可

###  Health Score

26

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~98 days

Total

7

Last Release

1615d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15a0610fee78753bdad92fd45c3506455c0fd45ae51924797b1841d260495a3f?d=identicon)[tiderjian](/maintainers/tiderjian)

---

Top Contributors

[![qq958691165](https://avatars.githubusercontent.com/u/13673962?v=4)](https://github.com/qq958691165 "qq958691165 (7 commits)")[![Xhiny](https://avatars.githubusercontent.com/u/35066497?v=4)](https://github.com/Xhiny "Xhiny (2 commits)")[![tiderjian](https://avatars.githubusercontent.com/u/1665649?v=4)](https://github.com/tiderjian "tiderjian (1 commits)")

### Embed Badge

![Health badge](/badges/quansitech-qscmf-formitem-tengxun-cos/health.svg)

```
[![Health](https://phpackages.com/badges/quansitech-qscmf-formitem-tengxun-cos/health.svg)](https://phpackages.com/packages/quansitech-qscmf-formitem-tengxun-cos)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
