title: Set default value in input type file
body: <blockquote>
    <p><strong>Note:</strong></p>
    
    <p>The answer(s) below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element via JavaScript in 2017.</p>
    
    <p>See the answer in this question for details as well as a demo:<br><a href="https://stackoverflow.com/q/47515232/584192">How to set file input value programatically (i.e.: when drag-dropping files)?</a></p>
  </blockquote>
  
  <p>I know this question is duplicated but I think maybe someone can help me.</p>
  
  <p>Let me ask first the problem.</p>
  
  <p>I have a form to update some fields: name, order, public, pathheader and pathhome and my question is this:</p>
  
  <p>It's possible to update the form, with the same value in pathheader and pathhome without clicking in the input type file again? </p>
  
  <p>The input type file looks like here:</p>
  
  <pre><code>@if (Storage::disk('projects')-&gt;has($project-&gt;slug))
      &lt;img src="{{ asset('/storage/projects/'.$project-&gt;slug.'/header.png') }}" id="img" class="img" style="width:100%;height:200px;background-color:#ccc;border:2px solid gray;"&gt;
  @else
      &lt;img src="" id="img" class="img" style="width:100%;height:200px;background-color:#ccc;border:2px solid gray;"&gt;
  @endif
  &lt;input type="file" name="pathheader" id="pathheader"  class="form-control-file" aria-describedby="fileHelp" style="display:none;"&gt;
  </code></pre>
  
  <p>So when I render the view, it shows the images I thinks it's not practical to find it in server and click it again, if you don't want to change it.</p>
  
  <p>Let me know your opinions, and if someone know how to do it i will be appreciated. (If know how to do it with some library or other functionalities let me know it.</p>
  
  <p>Thanks a lot.</p>
  
  <p><strong>SOLVED</strong> </p>
  
  <p>Easier way: Make data not required in controller.</p>
  
  <p>Inside the function:</p>
  
  <pre><code>public function updateProject(Request $request, $id) 
  {
      $this-&gt;validate($request, array(
          'slug'=&gt; 'required',
          'order'=&gt; 'required',
          'public'=&gt; 'required'
      ));
      $project = Project::find($id);
      $project-&gt;slug = $request-&gt;input('slug');
      $project-&gt;order = $request-&gt;input('order');
      $project-&gt;public = $request-&gt;input('public');
      if ($request-&gt;hasFile('pathheader')){
          $project-&gt;pathheader = $request-&gt;file('pathheader');
          \Storage::disk('projects')-&gt;putFileAs($project-&gt;slug,$project-&gt;pathheader,'header.png');
      }
      if ($request-&gt;hasFile('pathhome')){
          $project-&gt;pathhome = $request-&gt;file('pathhome');
          \Storage::disk('projects')-&gt;putFileAs($project-&gt;slug,$project-&gt;pathhome,'home.png');
  
      }
      $project-&gt;save();
      return redirect()-&gt;route('admin.projects.show', $project-&gt;id);
  }
  </code></pre>