PHPackages                             githen/laravel-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. githen/laravel-upload

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

githen/laravel-upload
=====================

基于Dropzone为laravel提供上传支持

v1.3.13(5mo ago)1699↓50%MITPHP

Since Apr 10Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/jiaoyu-cn/laravel-upload)[ Packagist](https://packagist.org/packages/githen/laravel-upload)[ RSS](/packages/githen-laravel-upload/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (26)Used By (0)

laravel-upload
==============

[](#laravel-upload)

基于Dropzone为laravel提供上传支持

[![image](https://camo.githubusercontent.com/854a7dcaceae0371ac05d3afedd3b11bf67d77dfd67021d629274aa1c2d09cf7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a69616f79752d636e2f6c61726176656c2d75706c6f6164)](https://github.com/jiaoyu-cn/laravel-upload/stargazers)[![image](https://camo.githubusercontent.com/619357a79209fc45829290056a079266d8fa8819698495f40f3bb2f2b2ae18c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6a69616f79752d636e2f6c61726176656c2d75706c6f6164)](https://github.com/jiaoyu-cn/laravel-upload/network/members)[![image](https://camo.githubusercontent.com/97a4ff04f9e54a17d9efb7bed4fa3b12f12b4d54e3f588e1428b8173f1506867/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6a69616f79752d636e2f6c61726176656c2d75706c6f6164)](https://github.com/jiaoyu-cn/laravel-upload/issues)

安装
--

[](#安装)

```
composer require githen/laravel-upload:~v1.3.0

# 迁移配置文件
php artisan vendor:publish --provider="Githen\LaravelUpload\UploadProvider"
```

配置文件说明
------

[](#配置文件说明)

在`config/filesystem.php`中添加目录`public`配置项

```
'localFile' => [
        'driver' => 'local',
        'root' => public_path(),
        'url' => config('app.url'), // 生成url前缀
        'permissions' => [
            'file' => [
                'public' => 0770,
                'private' => 0600,
            ],
            'dir' => [
                'public' => 0770,
                'private' => 0700,
            ],
        ],
    ],
```

生成`upload.php`上传配置文件

```
return [
    /**
    |--------------------------------------------------------------------------
    | 文件上传配置
    |--------------------------------------------------------------------------
    |  '标识' => [
     *      'size' => 3, //文件大小上限  类型int 单位MB
     *      'ext' => ['png', 'jpg']  // 支持的文件类型，类型array
     *      'resize' => [200, 200]  // 若为图片类型，自动处理图片为200X200
     *      'path' => 'uploads/'. date('Y/m/d'),  // 文件实际存储目录
     * ]
     */
    'global' => [
        'tmp' => 'uploads/tmp', // 临时目录，在表单提交时再将文件移动到path目录
        'path' => 'uploads', // 实际存储目录
        'name' => 'file',  // 文件上传时文件对应的key
        'auth' => ['auth'],  // 上传controller加载的中间件
        'filesystem' => 'localFile', // 使用的文件系统
        'thumb' => 'thumb', // 图片类型缩略图名称，a.png => a_thumb.png
    ],

    'img' => [
        'size' => 3, // MB
        'ext' => ['.png', '.jpg', '.jpeg', '.zip'],
        'resize' => [200,200], // 原图等比压缩，只有图片格式有效，不配置使用原图
        'thumb_resize' => [200,200], // 生成缩略图，只有图片格式有效，不配置则不生成
        'path' => 'uploads/'. date('Y/m/d'),
    ]
];
```

初始化上传实例
-------

[](#初始化上传实例)

自动发现功能将在6.0.0中删除，如果依赖此功能，需要手动关闭。默认生成的JS已处理，可忽略。

```
Dropzone.autoDiscover = false;
```

在`html`中引入`JS文件`

```

```

进行实例化

```
myDropzone = new uploadzone({
    dom: '#dpz-single-file',
    paramName: "{!! config('upload.global.name') !!}",
    acceptedFiles:"{!! implode(',', config('upload.img.ext')) !!}",

    // param为上传关联配置的标识 ，必填
    // is_tmp 决定使用哪个目录，false时，使用path配置目录，true时使用tmp目录
    url:"{!! route('jiaoyu.upload',['param' => 'img', 'is_tmp'=>true]) !!}",
    csrf:true,

    // 成功回调，可通过此方法处理返回文件信息
    success:function (file){
        if (file.status === "success"){
            var response = JSON.parse(file.xhr.response);
        }
    },

    // 失败回调,以下为默认方法，如不修改可省略
    error:function (file, data){
        if (file.previewElement){
            let message = data;
            if (typeof data.message !== "undefined") message = data.message
            if (typeof message !== "string" && message.error) {
                message = message.error;
            }
            for (let node of file.previewElement.querySelectorAll(
                "[data-dz-errormessage]"
            )) {
                node.textContent = message;
            }
        }
    },
    // 删除文件
    removedfile:function(file){

    },
    // 超过maxFiles限制回调处理
    maxfilesexceeded:function(file){

    }
})
```

参数名称说明备注dom实例化的DOM标识必填csrfPOST提交时的csrf验证非必填
truefalseacceptedFiles允许上传文件后缀(.jpg,.png)默认为.zipurl上传地址{!! route('jiaoyu.upload',\['param' =&gt; 'img', 'is\_tmp'=&gt;true\]) !!}`param`:标识（以此标识从`upload.php`中获取配置信息）
`is_tmp`:是否使用临时目录(`tmp`)，为false使用`path`目录paramName上传的属性名称非必填，默认:`file`chunkSize分片大小单位：MB,默认2MBmaxFiles最多上传文件数非必填，默认：1maxFilesize文件最大限制非必填，单位：MB,默认10MB,chunking是否分片forceChunking上传时显示文件详情，不可修改dictDefaultMessage默认提示语拖动文件至此处或点击上传dictMaxFilesExceeded超过限制上传数量提示语您最多上传的文件数为 + maxFilesdictResponseError上传失败提示语文件上传失败！dictInvalidFileType文件类型提示语文件类型支持dictFallbackMessage兼容性提示语浏览器不支持dictFileTooBig文件过大提示语文件过大，最大支持 + maxFilesize + MBdictRemoveFile删除提示语删除addRemoveLinks添加删除连接previewsContainer预览容器previewTemplate预览生成模板thumbnailWidth插件中，展示图宽度默认：120thumbnailHeight插件中，展示图高度默认：120临时目录迁移到正式目录
-----------

[](#临时目录迁移到正式目录)

如果上传的文件是放在临时目录`tmp`下，则在实际业务中，需要进行迁移文件到正式目录。可执行以下操作完成迁移操作。

```
//app('jiaoyu.move') 以单例形貌注入，执行迁移操作
// $from 文件地址
// $to    需要迁移到的目录
// 如果存在缩略图，一并迁移
$result = app('jiaoyu.upload')->move($from, $to);

// 返回数据结构
[
    "code" => 0, // 0 成功 1失败
    "message" => "成功", // 执行说明
    "path" => '', // 新文件的目录，缩略图默认在文件名后加入缩略图标识，`upload.global.thumb`
]
```

删除文件
----

[](#删除文件)

```
// $file 要删除的文件
$result = app('jiaoyu.upload')->remove($file);

// 返回数据结构
[
    "code" => 0, // 0 成功 1失败
    "message" => "成功删除", // 执行说明
]
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance71

Regular maintenance activity

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.3% 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 ~40 days

Recently: every ~58 days

Total

25

Last Release

164d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51a06d2f182ca37da5fc95e1fa8988248962856bc62e65dc0a5fbb420af3e9af?d=identicon)[githen](/maintainers/githen)

---

Top Contributors

[![githen-cn](https://avatars.githubusercontent.com/u/3197947?v=4)](https://github.com/githen-cn "githen-cn (23 commits)")[![nanjishidu](https://avatars.githubusercontent.com/u/15984590?v=4)](https://github.com/nanjishidu "nanjishidu (21 commits)")

### Embed Badge

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

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

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M75](/packages/aws-aws-sdk-php-laravel)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[farhanshares/laravel-mediaman

MediaMan - The most elegant &amp; powerful media management package for Laravel!

293.7k](/packages/farhanshares-laravel-mediaman)

PHPackages © 2026

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