All Projects → photogabble → Laravel Remember Uploads

photogabble / Laravel Remember Uploads

Licence: mit
Laravel Middleware and helper for remembering file uploads during validation redirects

Projects that are alternatives of or similar to Laravel Remember Uploads

Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+376.12%)
Mutual labels:  middleware, laravel, laravel-package, laravel-5-package
Laravel Achievements
Achievements for Laravel 5.3+
Stars: ✭ 279 (+316.42%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Api Health
Monitor first and third-party services and get notified when something goes wrong!
Stars: ✭ 65 (-2.99%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Administrator
a fork from Frozennode/Administrator
Stars: ✭ 296 (+341.79%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+243.28%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Gitscrum
GitScrum is a Project Management Tool, developed to help entrepreneurs, freelancers, managers, and teams Skyrocket their Productivity with the Agile methodology and Gamification.
Stars: ✭ 2,686 (+3908.96%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Gamp
📊 Laravel Google Analytics Measurement Protocol Package
Stars: ✭ 271 (+304.48%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Js Localization
🌐 Convert your Laravel messages and consume them in the front-end!
Stars: ✭ 451 (+573.13%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Telegram
✈️ Telegram Notifications Channel for Laravel
Stars: ✭ 450 (+571.64%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Server Monitor
Server Monitoring Command for Laravel Applications
Stars: ✭ 424 (+532.84%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Sneaker
An easy way to send emails whenever an exception occurs on server.
Stars: ✭ 223 (+232.84%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (-32.84%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Hooks
Hooks is a extension system for your Laravel application.
Stars: ✭ 202 (+201.49%)
Mutual labels:  laravel, laravel-package, laravel-5-package
L5 Very Basic Auth
Stateless HTTP basic auth for Laravel without the need for a database.
Stars: ✭ 127 (+89.55%)
Mutual labels:  middleware, laravel, laravel-5-package
Voyager Frontend
The Missing Front-end for The Missing Laravel Admin 🔥
Stars: ✭ 200 (+198.51%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Voyager Hooks
Hooks system integrated into Voyager.
Stars: ✭ 200 (+198.51%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Laravel Page Speed
Package to optimize your site automatically which results in a 35%+ optimization
Stars: ✭ 2,097 (+3029.85%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (+195.52%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Generator
Laravel 5.3+ Scaffold Generator, Support both bootstrap and Semantic UI
Stars: ✭ 327 (+388.06%)
Mutual labels:  laravel, laravel-package, laravel-5-package
Orm
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen
Stars: ✭ 712 (+962.69%)
Mutual labels:  laravel, laravel-package, laravel-5-package

Laravel Remember Uploads

Middleware Package

Build Status Latest Stable Version License

About this package

This middleware solves the issue of unrelated form validation errors redirecting the user back and loosing the files that had been uploaded. It does this by temporarily caching server-side the file fields that have passed validation so that they may be processed once the whole form has been submitted passing validation.

Install

Add to your project with composer via composer require photogabble/laravel-remember-uploads.

Laravel Version >= 5.5

This library supports package auto-discovery in Laravel >= 5.5.

Laravel Versions 5.2 - 5.5

To enable the package you will need to add its service provider to your app providers configuration in Laravel.

'providers' => [
    // ...
    
    Photogabble\LaravelRememberUploads\RememberUploadsServiceProvider::class,
    
    // ...
],

Usage

You need to assign the middleware remember.files to routes that process uploaded files; in the case of CRUD terminology that would be the create and update methods.

So that the middleware is aware of remembered files from the previous request you need to include a reference by way of using a hidden input field with the name _rememberedFiles.

@if( $oldFile = rememberedFile('file'))
    <input type="hidden" name="_rememberedFiles[file]" value="{{ $oldFile->getFilename() }}">
@else
    <input type="file" name="file">
@endif

Then within your controller code you can obtain the file via the rememberedFile helper:

function store(Illuminate\Http\Request $request) {    
    if ($file = $request->file('img', rememberedFile('img')) {
        // ... File exists ...
    }
}

The $file variable will equal an instance of Symfony\Component\HttpFoundation\File\UploadedFile if the file has been posted during the current request or remembered.

This example is viewable as a test case within this libaries tests.

Array File Fields

In the case where you have multiple upload fields sharing the same name for example image[0], image[1]; the helper rememberedFile('image') will return an array of Symfony\Component\HttpFoundation\File\UploadedFile.

The reference _rememberedFiles will also need to match the array syntax of the file inputs it mirrors:

@if( $oldFile = rememberedFile('image'))
    <!-- $oldFile is now an array of Symfony\Component\HttpFoundation\File\UploadedFile -->
    <input type="hidden" name="_rememberedFiles[image][0]" value="{{ $oldFile[0]->getFilename() }}">
    <input type="hidden" name="_rememberedFiles[image][1]" value="{{ $oldFile[1]->getFilename() }}">
@else
    <input type="file" name="image[0]">
    <input type="file" name="image[1]">
@endif
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].