PHPackages                             jzh/upload - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. jzh/upload

ActiveLibrary[File &amp; Storage](/categories/file-storage)

jzh/upload
==========

webman upload plugin

v1.0.5(1y ago)0391MITPHPPHP &gt;=7.2

Since Apr 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Jzh-thub/webman-upload)[ Packagist](https://packagist.org/packages/jzh/upload)[ RSS](/packages/jzh-upload/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (5)Versions (11)Used By (0)

webman 上传插件
===========

[](#webman-上传插件)

特性
--

[](#特性)

- 本地多文件上传(本地、阿里云、腾讯云、七牛云)
- `Base64`图片文件上传
- 上传服务端文件
- 获取上传密钥

安装
--

[](#安装)

```
composer require jzh/upload
```

基本用法
----

[](#基本用法)

```
$upload=Jzh\Upload\Upload::config(); // 初始化。 默认为本地存储：local，阿里云：oss，腾讯云：cos，七牛：qiniu
$res = $upload->uploadFile();
if($res){
var_dump(json_encode($res));
}else{
    $res->getMessage();
    //or
    $res->setError();
}
```

### 上传成功信息

[](#上传成功信息)

```
[
    {
        "key": "webman",
        "origin_name": "常用编程软件和工具.xlsx",
        "save_name": "03414c9bdaf7a38148742c87b96b8167.xlsx",
        "save_path": "runtime/storage/03414c9bdaf7a38148742c87b96b8167.xlsx",
        "url": "/storage/fd2d472da56c71a6da0a5251f5e1b586.png",
        "uniqid ": "03414c9bdaf7a38148742c87b96b8167",
        "size": 15050,
        "mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        "extension": "xlsx"
    }
    ...
]
```

> 失败，抛出`UploadException`异常

### 成功响应字段

[](#成功响应字段)

字段描述示例值key上传文件keywebmanorigin\_name原始文件名常用编程软件和工具.xlsxsave\_name保存文件名03414c9bdaf7a38148742c87b96b8167.xlsxsave\_path文件保存路径（相对）/var/www/webman-admin/runtime/storage/03414c9bdaf7a38148742c87b96b8167.xlsxurlurl访问路径/storage/03414c9bdaf7a38148742c87b96b8167.xlsxunique\_iduniqid03414c9bdaf7a38148742c87b96b8167size文件大小15050（字节）mime\_type文件类型application/vnd.openxmlformats-officedocument.spreadsheetml.sheetextension文件扩展名xlsx上传验证
----

[](#上传验证)

支持使用验证类对上传文件的验证，包括文件大小、文件类型和后缀

字段描述示例值single\_limit单个文件的大小限制，默认200M1024 \* 1024 \* 200total\_limit所有文件的大小限制，默认200M1024 \* 1024 \* 200nums文件数量限制，默认1010include被允许的文件类型列表\['xlsx','pdf'\]exclude不被允许的文件类型列表\['png','jpg'\]支持上传SDK
-------

[](#支持上传sdk)

#### 阿里云对象存储

[](#阿里云对象存储)

```
composer require aliyuncs/oss-sdk-php
```

#### 腾讯云对象存储

[](#腾讯云对象存储)

```
composer require qcloud/cos-sdk-v5
composer require qcloud_sts/qcloud-sts-sdk
```

#### 七牛云云对象存储

[](#七牛云云对象存储)

```
composer require qiniu/php-sdk
```

上传Base64图片
----------

[](#上传base64图片)

> **使用场景：** 前端直接截图（头像、Canvas等）一个Base64数据流的图片直接上传到云端

#### 请求参数

[](#请求参数)

```
{
    "extension": "png",
    "base64": "data:image/jpeg;base64,/9j/4AAQSkxxxxxxxxxxxxZJRgABvtyQBIr/MPTPTP/2Q=="
}
```

#### 请求案例（阿里云）

[](#请求案例阿里云)

```
public function upload(Request $request)
{
   $upload= Jzh\Upload\Upload::config(Jzh\Upload\Upload::MODE_OSS, false); // 第一个参数为存储方式。第二个参数为是否是文件（默认是）
    $base64 = $request->post('base64');
    $r = $upload->uploadBase64($base64,'png');
    var_dump($r);
}
```

#### 响应参数

[](#响应参数)

```
{
	"save_path": "storage/20220402213639624851671439e.png",
	"url": "http://webman.oss.com/storage/20220402213639624851671439e.png",
	"unique_id": "20220402213639624851671439e",
	"size": 11802,
	"extension": "png"
}
```

上传服务端文件
-------

[](#上传服务端文件)

> **使用场景：** 服务端导出文件需要上传到云端存储，或者零时下载文件存储。

#### 请求案例（阿里云）

[](#请求案例阿里云-1)

```
$upload=Jzh\Upload\Upload::config(Jzh\Upload\Upload::MODE_OSS,false);
$localFile = public_path() . DIRECTORY_SEPARATOR . 'public/webman.png';
$res = $upload->uploadServerFile($localFile);
```

#### 响应参数

[](#响应参数-1)

```
{
	"origin_name": "webman.png",
	"save_path": "storage/6edf04d7c26f020cf5e46e6457620220402213414.png",
	"url": "http://webman.oss.com/storage/6ed9ffd54d0df57620220402213414.png",
	"unique_id": "6edf04d7c26f020cf5e46e6403213414",
	"size": 3505604,
	"extension": "png"
}
```

获取上传密钥
------

[](#获取上传密钥)

> **使用场景：** 获取密钥 用于前端上传

#### 请求案例（阿里云）

[](#请求案例阿里云-2)

```
$upload=Jzh\Upload\Upload::config(Jzh\Upload\Upload::MODE_OSS,false);
$res = $upload->getTempKeys();
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance46

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~123 days

Recently: every ~167 days

Total

10

Last Release

419d ago

Major Versions

v0.0.4 → v1.0.02023-07-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/18be0a4a9d7b5cab20e5f886d8c9a3e1362b5188f6e4c625db8895e7091bc0e5?d=identicon)[Jzh-thub](/maintainers/Jzh-thub)

---

Top Contributors

[![Jzh-thub](https://avatars.githubusercontent.com/u/74651570?v=4)](https://github.com/Jzh-thub "Jzh-thub (10 commits)")

### Embed Badge

![Health badge](/badges/jzh-upload/health.svg)

```
[![Health](https://phpackages.com/badges/jzh-upload/health.svg)](https://phpackages.com/packages/jzh-upload)
```

PHPackages © 2026

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