Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Remember Uploads Laravel Package

photogabble/laravel-remember-uploads

Laravel package that remembers file uploads between requests, helping uploaded files survive validation failures and form redisplay. It stores temporary uploads and simplifies repopulating file inputs without forcing users to upload again.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. composer require the package.
  2. Service provider: on Laravel 5.5+ (new in 1.3.0) auto-discovery handles registration — no manual config/app.php entry required. On older versions, add the provider to providers and the facade/alias to aliases as documented.
  3. Publish config: php artisan vendor:publish and review the new storage / temporary-path key (added in #16). Defaults work for a single app; override for multi-tenant or containerised setups.
  4. Register the middleware on the routes that handle uploads (typically the web group). The middleware is what intercepts incoming file inputs and persists them to temporary storage when validation fails.
  5. First use case: a form with <input type="file" name="avatar"> and a validate() call. On a failed submission the file survives the redirect; in your Blade view call rememberedFile('avatar') to retrieve it and repopulate the field.

Start by reading the (substantially improved in #17) README — particularly the middleware registration and config sections — then trace a single upload through validation failure to rememberedFile().

Implementation Patterns

  • Validation-failure repopulation (primary pattern). Let the middleware stash files, then in the controller/Blade check rememberedFile('field') and decide whether to re-display, re-process, or promote to permanent storage. Do not manually move() on the failed request — the middleware already captured it.
  • Array / multiple file inputs. As of the #15 bugfix the middleware intercepts array file inputs (name="documents[]" with multiple), so the same rememberedFile('documents') call returns the collection. This makes multi-upload forms finally behave like single-field ones.
  • Custom temporary storage path (#16). Set the path in the published config rather than relying on the package default — useful when you need temp files on a shared volume, scoped per tenant, or on a disk that outlives individual requests. Keep it on the same filesystem the app can read at request time.
  • Blade helper usage. Wrap retrieval so missing files degrade gracefully: show a filename/link only when rememberedFile() is non-null, otherwise render a plain file input. This keeps the "remember me" affordance invisible on first load.
  • Integration ordering. Place the middleware before anything that reads/consumes $request->file() (validation middleware, form-request authorisation is fine, but your own upload-handling middleware should run after it).
  • Legacy compatibility. If you still support <5.5, keep explicit provider registration in config/app.php; feature-detect rather than branching per environment.

Gotchas and Tips

  • oldFile() is deprecated. Swap every call to rememberedFile(). It still works in 1.3.0, but expect removal in a future major — grep your views and keep the rename in one commit so the diff is reviewable.
  • The array-input fix changed behaviour. Prior to 1.3.0, array file inputs were silently not intercepted by the middleware. If you had a custom workaround (manual stash loop, per-index handling), remove it — it now double-handles and can produce duplicate/conflicting temp files.
  • Silent null returns. When rememberedFile() returns null, the usual cause is that the middleware never ran (wrong route group, ordering, or excluded path). Check middleware registration before suspecting the storage path.
  • Temp-file lifecycle. Remembered files live in temporary storage until promoted or cleaned. In production, point the config path at a disk with a cleanup policy (cron / scheduled prune) — otherwise uploads accumulate. The configurable path (#16) is what makes this manageable; use it deliberately.
  • Storage path config quirks. The path must be writable by the PHP process and readable by the request that retrieves it — on multi-server setups this means a shared mount, not the local ephemeral disk. Avoid trailing-slash inconsistencies in the config value.
  • Auto-discovery only covers 5.5+. On 5.4 and below, forgetting manual registration presents as "class not found" or a middleware that never fires — same symptom set as above, so confirm your Laravel version first.
  • Debugging tip. Temporarily log $request->file() and the resolved temp path inside the middleware to confirm interception; then confirm the same path resolves in the controller. If both match, the problem is your view call, not the package.
  • Docs are now trustworthy. #17 improved documentation substantially — prefer the README over older blog posts, which predate the rememberedFile rename and the array-input fix.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource