I am working on a Laravel project and I have routes set up for a form page where it shows the form on GET and it analyzes it on POST:
Route::get('/update-data', [
'as' => 'user.settings.edit-data',
'uses' => 'UserController@editData',
]);
Route::post('/update-data', [
'as' => 'user.settings.update-data',
'uses' => 'UserController@updateData',
]);
In this form I ask the user to fill out two fields with text and I also ask them to upload two files. Both files must be jpeg, png or pdf. In the controller I have:
$this->validate($request,
[
'phone' => 'required',
'email' => 'required|email',
'file1' => 'required|mimes:jpeg,png,pdf',
'file2' => 'required|mimes:jpeg,png,pdf',
]);
If that succeeds, then the code will continue executing and save everything, but if not it will redirect the user back to the form. Is there a way to still have the file chosen so that the user doesn't need to look for it again?