Restoring the value of a input type=file after failed validation
You cannot populate the file input, to do so would be a serious security problem.
Instead, store the uploaded content on the server and store an id that you can use to reference it in a hidden input.
Clean the files up automatically after they reach a certain age, and provide a means for the user to change their mind about what file they want to upload (e.g. a checkbox (checked by default) for each file being stored on the server for upload)
Form::file: How to repopulate with Input::old After Validation Errors and/or on Update?
Apparently you can't.
Browsers don't allow you to set a value on a file input for security reasons.
There are two silimar questions, not laravel related but i think answers could help you:
Can you re-populate file inputs after failed form submission with PHP or JavaScript?
Restoring the value of a input type=file after failed validation
How to keep input type=file field value after failed validation in ASP.NET MVC?
Browsers are designed in such way because of security risks. It's impossible to set value of file input box in HTML source or by Javascript. Otherwise malicious script could steal some private file without user attention.
There is an interesting information about the subject.
Can you re-populate file inputs after failed form submission with PHP or JavaScript?
I think the short answer here is no. You can't repopulate file upload fields. However, you can work around it.
If a file has been selected and the form submitted, then you've already received the file. What you can do is keep a reference to the file on disk and put that in a hidden field and show a message to indicate to the user you still have their file uploaded so it does not need to be replaced/re-uploaded. When your form gets submitted again without a file, you can check for the hidden field value and use that to get your local copy of the file they uploaded in their last attempt.
The other way to do this is to either submit the form via ajax (using either flash or the iframe method for the file upload) or to do an ajax call to validate the form first, and then only submit as normal if valid (thus no form reload, no loss of file upload field data).
Can you re-populate file inputs after failed form submission with PHP or JavaScript?
I think the short answer here is no. You can't repopulate file upload fields. However, you can work around it.
If a file has been selected and the form submitted, then you've already received the file. What you can do is keep a reference to the file on disk and put that in a hidden field and show a message to indicate to the user you still have their file uploaded so it does not need to be replaced/re-uploaded. When your form gets submitted again without a file, you can check for the hidden field value and use that to get your local copy of the file they uploaded in their last attempt.
The other way to do this is to either submit the form via ajax (using either flash or the iframe method for the file upload) or to do an ajax call to validate the form first, and then only submit as normal if valid (thus no form reload, no loss of file upload field data).
How to retain file input value after form submission with errors?
i think you already suggested the answer to your problem . it owuld be better to validate other fields of the form using ajax and don't submit the file initially. anbd if you have some problems with the file you can have some basic checks for your file using like file extension using ajax
Related Topics
Font Awesome Is Not Showing Icon
How to Display Text, a Dotted Line Then More Text Spanning the Width of the Page
How to Handle HTML5 Constraint Validation Pop-Up Using Selenium
Change the Z Index of Flash Content
How to Avoid Wrapping in CSS Float
Using Os 9 Resource Fork Fonts in CSS with @Font-Face
Placing a <Div> Within a <Canvas>
"Invalid Form Control" Only in Google Chrome
How to Add Border to a Container with Transparent Gaps in Between
How to Make Images Stay Within the Rows of a CSS Grid Container
Flexbox Resize and Scrollable Overflow
How to Select an Element That Has an Id Which Begins with a Digit