PHPackages                             cybex/laravel-lodor - 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. cybex/laravel-lodor

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

cybex/laravel-lodor
===================

Provides easy support for processing chunked uploads in Laravel.

v0.7.0(4y ago)36.1k—0%MITPHPPHP ^8.0

Since Jun 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/cybex-gmbh/laravel-lodor)[ Packagist](https://packagist.org/packages/cybex/laravel-lodor)[ Docs](https://github.com/cybex-gmbh/laravel-lodor)[ RSS](/packages/cybex-laravel-lodor/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (29)Used By (0)

Laravel Lodor
=============

[](#laravel-lodor)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bf6fda66c025d8d431685fe6305f2d27531b32d7061ca433d7bd26b49db54061/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63796265782f6c61726176656c2d6c6f646f722e737667)](https://packagist.org/packages/cybex/laravel-lodor)[![Packagist Downloads](https://camo.githubusercontent.com/0a15cc353aa41d2a41c41ff167ba1cdfb9bb4b0b7124e0ba657913e48a1dd225/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63796265782f6c61726176656c2d6c6f646f722e737667)](https://packagist.org/packages/cybex/laravel-lodor)[![Github build status](https://github.com/cybex-gmbh/laravel-lodor/workflows/tests/badge.svg)](https://github.com/cybex-gmbh/laravel-lodor/workflows/tests/badge.svg)[![GitHub pull-requests](https://camo.githubusercontent.com/924380e8d909097d21d29cbe60b6554baf8e61720c15a717f667324a08d97e43/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f63796265782d676d62682f6c61726176656c2d6c6f646f722e737667)](https://github.com/cybex-gmbh/laravel-lodor/pull/)[![GitHub issues](https://camo.githubusercontent.com/da8d9e0d073844ebd57baa7298a819c1a13136534455d4f200d86b02eabcc0a6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f63796265782d676d62682f6c61726176656c2d6c6f646f722e737667)](https://github.com/cybex-gmbh/laravel-lodor/issues/)[![GitHub contributors](https://camo.githubusercontent.com/fb26abe3c0fa82b2c1b9b9c49c959597ccb01b63825e89c6921b6f87946cf3d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f63796265782d676d62682f6c61726176656c2d6c6f646f722e737667)](https://github.com/cybex-gmbh/laravel-lodor/graphs/contributors/)[![Laravel Version](https://camo.githubusercontent.com/67ee5d81a5376004a1b8b4a10665b94d2936154d5eae3d000329b5eb63782b3c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d696e696d756d5f4c61726176656c5f56657273696f6e2d362e782d7265642e737667)](https://laravel.com/docs/6.x)

This package for Laravel 6.x or newer provides an easy way to implement simple as well as chunked uploading from frontend libraries like DropzoneJS or ResumableJS and implement custom synchronous or asynchronous post-processing through (queued) listeners thanks to its use of Laravel Events.

The package is not available for older Laravel versions because the support for versions below 6.0.0 has run out.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require cybex/laravel-lodor
```

Security
--------

[](#security)

Please note that by default, the upload and polling routes are protected by web and auth middleware for security reasons. This means that *Lodor* will only work on authenticated routes and when called with a CSRF token. Otherwise you will get a HTTP 401 response when trying to upload or poll.

Please refer to the [Laravel Documentation on CSRF protection](https://laravel.com/docs/csrf) and [Authentication](https://laravel.com/docs/authentication) for further reading.

### Customizing the Route Middleware

[](#customizing-the-route-middleware)

It is encouraged to leave the web middleware active at all times to ensure protection against CSRF. However, there might be times when you want to allow uploads by users without logging in to your site, e.g. on contact forms.

You can customize the middleware that is applied to the routes registered by *Lodor* by adjusting the `route_middleware` array in the [Configuration](#Configuration).

Usage
-----

[](#usage)

To get started with a simple HTML file upload, the only thing you really have to do is to set the action of your file upload form to the *Lodor* upload route:

```

    @csrf
    Upload a file with Lodor:

```

By default, *Lodor* registers a POST route at `/uploadmedia`, and all simple uploads go straight to the `lodor/uploads` directory in the storage path of your Laravel application.

The HTML form above will upload the file to your storage directory and, by default, return a JSON with a success indicator and uuid like:

```
{"success":true,"uuid":"ffb3dfe7-9029-4b9a-abfe-5e7485592561"}

```

This setup is useful for asynchronous uploads using Javascript, particularly when using libraries like [Dropzone.js](https://www.dropzonejs.com) or [Resumable.js](http://www.resumablejs.com).

### Redirecting to a Controller after Upload

[](#redirecting-to-a-controller-after-upload)

If you want to process the form yourself instead after the upload completed, you may define a named route by the name of `lodor_uploaded` like this:

```
Route::post('/uploaded')->uses('SomeController@uploaded')->name('lodor_uploaded');
```

If this named route exists, Lodor will automatically redirect the request to the specified controller action instead of returning a JSON response. The controller method should be declared as follows:

```
