title: laravel | How to replace a field in form's request?
body: <p>I am using laravel 5.4 and I'm trying to replace the imagePath field in my request (renaming the uploaded image).</p>
  
  <p><strong>explanation:</strong></p>
  
  <p>when the form is submitted the request field(<code>request-&gt;imagePath</code>) contains the temporary location of the uploaded image, I am moving that tmp image to a dir while changing its name (<code>$name</code>). so now as the <code>request-&gt;imagePath</code> still has old tmp image location I want to change <code>request-&gt;imagePath</code> value to have the new location and then create the user.</p>
  
  <p>Like so</p>
  
  <pre><code>     if($request-&gt;hasFile('imagePath')) 
       {
              $file = Input::file('imagePath');
  
              $name = $request-&gt;name. '-'.$request-&gt;mobile_no.'.'.$file-&gt;getClientOriginalExtension();
  
               echo $name."&lt;br&gt;";
  
              //tried this didn't work
              //$request-&gt;imagePath = $name;
  
              $file-&gt;move(public_path().'/images/collectors', $name);
  
              $request-&gt;merge(array('imagePath' =&gt; $name));
  
              echo $request-&gt;imagePath."&lt;br&gt;";
       }
  </code></pre>
  
  <p>But Its not working, Here is the output</p>
  
  <pre><code> mahela-7829899075.jpg
  
   C:\xampp\tmp\php286A.tmp
  </code></pre>
  
  <p>Please Help</p>