As the title says - I'm trying to redirect back to previous page, with input data, like this:
return Redirect::back()->withInput();
It works as intended for regular input, but not for files! Is there a workaround for this? So that after the redirect, the previous file is selected again.
If you just want to redirect a user back to the previous page (the most common example - is to redirect back to the form page after data validation failed), you can use this: return redirect()->back();
You may use Redirect::intended function. It will redirect the user to the URL they were trying to access before being caught by the authenticaton filter.
It won't work.
When you redirect something in Laravel it stores $_POST and $_GET in Session to get you data back in the next request. Files comes in a special PHP global var, $_FILES, because they are not really in memory, they are in disk and just some info about them in memory.
Storing those files in Session could cost too much in resources, imagine storing them in the Session you store in database... Yeah, Laravel or Symfony could create a layer to deal with it, looks easy at first sight, but looks like they just decided not to.
So, IMO, if you need them in the next request, move them to a temporary area and Session::put() the info about them, so you can just Session::get() them in the next request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With