title: How to update image with PUT method in Laravel REST API?
body: <p>I am trying to build a REST API with Laravel where users need to update their image. But, If I use PUT method in postman it does not update the image or store the image in designated folder. If I use POST instead it does update the image and also saves in the folder. But it does not save the file in database as I customize the name to store in DB. What could be the reason. Help is really necessary. TIA.</p>
  <p>Update Code</p>
  <pre><code>public function update(Request $request, $id)
  {
      $found = Partner::find($id);
      if (!$found) {
          return Response::json(['message' =&gt; 'Id not found'], 404);
      }
      $validatedData = Validator::make($request-&gt;all(), [
          'company_logo' =&gt; 'sometimes|mimes:jpg,png,jpeg|max:3048',
          'company_name' =&gt; 'sometimes|max:130',
          'company_email' =&gt; 'sometimes|email',
          'password'  =&gt;  'sometimes|min:6',
          'phone'  =&gt;  'sometimes|min:6|max:11',
          'address'  =&gt;  'sometimes',
          'city'  =&gt;  'sometimes|string',
          'country' =&gt;  'sometimes|string' ,
          'business_category'  =&gt;  'sometimes|string',
          'website_link' =&gt;  'nullable|string',
          'facebook_page' =&gt;  'nullable|string'
      ]);
      if ($validatedData-&gt;fails()) {
          return Response::json(['success' =&gt; false, 'message' =&gt; $validatedData-&gt;errors()], 400);
      }
  
      if ($request-&gt;hasFile('company_logo')) {
          $logo = $request-&gt;company_logo;
          $fileName = date('Y') . $logo-&gt;getClientOriginalName();
          $request-&gt;company_logo-&gt;storeAs('company_logo', $fileName, 'public');
          $found['company_logo'] = $fileName;
      }
      
      $found-&gt;update($request-&gt;all());
  
      return Response::json(['success' =&gt; true, 'message' =&gt; 'Partner updated successfully!', 
                             'updated_data' =&gt; $found], 200);
  }
  </code></pre>
  <p>My route</p>
  <pre><code>Route::group(['prefix' =&gt; 'partner'], function () {
  Route::post('store', [APIMemberController::class, 'store']);
  Route::post('update/{id}', [APIPartnerController::class, 'update']); // This works
  // Route::put('update/{id}', [APIPartnerController::class, 'update']); // This don't why?
  });
  </code></pre>
  <p>Storing partner</p>
  <pre><code>public function store(Request $request)
  {
      $validatedData = Validator::make($request-&gt;all(), [
          'company_logo' =&gt; 'required|mimes:jpg,png,jpeg|max:3048',
          'company_name' =&gt; 'required|max:130',
          'company_email' =&gt; 'required|email|unique:partners',
          'password'  =&gt;  'required|min:6',
          'phone'  =&gt;  'required|min:6|max:11',
          'address'  =&gt;  'required',
          'city'  =&gt;  'required|string',
          'country' =&gt;  'required|string' ,
          'business_category'  =&gt;  'required|string',
          'website_link' =&gt;  'nullable|string',
          'facebook_page' =&gt;  'nullable|string'
      ]);
  
      if ($validatedData-&gt;fails()) {
          return Response::json(['success' =&gt; false, 'message' =&gt; $validatedData-&gt;errors()], 400);
      }
  
      // $saved = Partner::create($request-&gt;all());
  
      if ($request-&gt;hasFile('company_logo')) {
          $logo = $request-&gt;file('company_logo');
          $fileName = date('Y') . $logo-&gt;getClientOriginalName();
          $request-&gt;company_logo-&gt;storeAs('company_logo', $fileName, 'public');
      }
  
      $partner = new Partner();
      
      $partner-&gt;company_logo = $request-&gt;company_logo-&gt;getClientOriginalName();
      $partner-&gt;company_name = $request-&gt;company_name;
      $partner-&gt;company_email = $request-&gt;company_email;
      $partner-&gt;password = $request-&gt;password;
      $partner-&gt;phone = $request-&gt;phone;
      $partner-&gt;address = $request-&gt;address;
      $partner-&gt;city = $request-&gt;city;
      $partner-&gt;country = $request-&gt;country;
      $partner-&gt;business_category = $request-&gt;business_category;
      $partner-&gt;website_link = $request-&gt;website_link;
      $partner-&gt;facebook_page = $request-&gt;facebook_page;
      $partner-&gt;save();
      return Response::json(['success' =&gt; 'Partner created successfully!', 'created_partner' =&gt; $partner], 201);
  
  
  }
  </code></pre>