title: Change PUT request to POST request to include image update
body: <p>I wrote a post edit method which at first consisted only of text. I did the update using a PUT request.</p>
  
  <p>Now I want to include images to my posts, so I added it, and it works for my POST request of creating a post but doesn't work for my update post, when I want to change image, since PUT request doesn't support file uploads.</p>
  
  <p>So now I'm stuck trying to change my update method from PUT request that only updates text to a POST request that updates both the text and an image if supplied.</p>
  
  <p>This is the code I wrote so far:</p>
  
  <pre><code>public function update(Request $request, Post $post)
  {
      //store updated image
      if($request-&gt;hasFile('image') &amp;&amp; $request-&gt;file('image')-&gt;isValid()){
          if($post-&gt;hasMedia('posts')) {
              $post-&gt;media()-&gt;delete();
          }
          $post-&gt;addMediaFromRequest('image')-&gt;toMediaCollection('post', 's3');
      }
      $post-&gt;update(request()-&gt;validate([
          'body' =&gt; 'required'
      ]));
      return redirect($post-&gt;path());
  }
  </code></pre>
  
  <p>I think that the $post->update doesn't work for the POST request. I just want to update a text if an update was given.</p>
  
  <p>Using Laravel 6.</p>
  
  <p><strong>EDIT</strong>: My form layout structure (simplified)</p>
  
  <pre><code>&lt;form action="action="/posts/{post}" method="POST"&gt;
      @method('PUT')
      @csrf
      &lt;div class="form-group row"&gt;
          &lt;input id="body" type="text" class="form-control" name="body" value="{{ old('body', $post-&gt;body) }}"&gt;
          &lt;input id="image" type="file" class="form-control" name="image"&gt;
          &lt;button type="submit" class="btn btn-primary"&gt;Update Post&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My routes:</p>
  
  <pre><code>Route::get('/posts/{post}/edit', 'PostsController@edit')-&gt;name('posts.edit');
  Route::put('/posts/{post}', 'PostsController@update');
  </code></pre>