title: laravel rest api upload file to server
body: <p>Am creating a REST api with laravel that allows a user to select an image file from their android device, then upload it to the server. The mage is converted to base64 before it's sent to the server alongside other parameters. I want to convert this base64 to a file and store it on the server then generate a link that can be used to access it. here is what i have tried so far and it doesnt work: I have already created a symlink to storage </p>
  
  <pre><code>public function create(Request $request)
  {
          $location = new Location();
          $location-&gt;name = $request-&gt;location_name;
          $location-&gt;latitude = $request-&gt;latitude;
          $location-&gt;longitude = $request-&gt;longitude;
  
          $location-&gt;saveOrFail();
  
          $provider = new Provider();
          $provider-&gt;name = $request-&gt;provider_name;
          $provider-&gt;location_id = $location-&gt;id;
          $provider-&gt;category_id = $request-&gt;category_id;
          $provider-&gt;description = $request-&gt;description;
          $provider-&gt;image = request()-&gt;file(base64_decode($request-&gt;encoded_image))-&gt;store('public/uploads');
  
  
          $provider-&gt;saveOrFail();
  
          return json_encode(array('status'=&gt;'success', 'message'=&gt;'Provider created successfully'));
  
  
  }
  </code></pre>