You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* ✨ Support Auto-Discovery #10 (#11)
* 📝 add build status
* Fixes#15 (#18)
* Failing test written as confirmation of issue #15
* added remembered file entity
* construct from and export to UploadedFile
* Compose with RememberedFile instead of array
* Use Illuminate UploadedFile, this is for Laravel after all
* working towards solving #15
* Memo to self
* notes
* Made much more DRY
* Wrote testArrayFileUploadOldRemembered test
* Added RememberedFileBag
* Refactored to add functionality for issue #15
* Removed final inspection warning
* Added failing test for checking validation errors invalidate array uploads
* Update to support laravel 5.4 as a minimum
* Fix unit test
* Remove composer.lock this is a lib not a project
* Replace Illuminate UploadedFile with Symfony UploadedFile
* Test able to reproduce bug discovered by Jarosław Goszowski on issue #15
* Fixed
* Amended documentation for #17
* Added configuration as per #16
This middleware allows the application to capture uploaded files and temporarily store them just-in-case the form validation redirects back otherwise losing the files before your controller could process them.
12
+
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.
12
13
13
14
## Install
14
15
15
16
Add to your project with composer via `composer require photogabble/laravel-remember-uploads`.
16
17
18
+
### Laravel Version >= 5.5
19
+
20
+
This library supports [package auto-discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518) in Laravel >= 5.5.
21
+
22
+
### Laravel Versions 5.2 - 5.5
23
+
17
24
To enable the package you will need to add its service provider to your app providers configuration in Laravel.
18
25
19
26
```php
@@ -26,11 +33,11 @@ To enable the package you will need to add its service provider to your app prov
26
33
],
27
34
```
28
35
29
-
Now you can assign the middleware `remember.files` to routes that you want the packages functionality to operate on.
30
-
31
36
## Usage
32
37
33
-
To ensure that remembered files remain as such across page refreshes (due to other validation errors) you need to include a reference by way of using a hidden input field with the name `_rememberedFiles`.
38
+
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.
39
+
40
+
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`.
34
41
35
42
```php
36
43
@if( $oldFile = rememberedFile('file'))
@@ -52,4 +59,21 @@ function store(Illuminate\Http\Request $request) {
52
59
53
60
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.
54
61
55
-
This example is viewable as a test case [within this libaries tests](https://github.com/photogabble/laravel-remember-uploads/blob/master/tests/UploadTest.php#L114).
62
+
This example is viewable as a test case [within this libaries tests](https://github.com/photogabble/laravel-remember-uploads/blob/master/tests/UploadTest.php#L192).
63
+
64
+
### Array File Fields
65
+
66
+
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`.
67
+
68
+
The reference `_rememberedFiles` will also need to match the array syntax of the file inputs it mirrors:
69
+
70
+
```php
71
+
@if( $oldFile = rememberedFile('image'))
72
+
<!-- $oldFile is now an array of Symfony\Component\HttpFoundation\File\UploadedFile -->
0 commit comments