title: How do I store a base64 encoded image inside of laravel using the storeas method()?
body: <p>I am at the end of my wisdom trying to use the StoreAs method in Laravel to store an image that has not been attached by the html file handler and has been sent through request being of type "File".</p>
  
  <p>I have created a cropped image using croppie: <a href="https://foliotek.github.io/Croppie/" rel="nofollow noreferrer">https://foliotek.github.io/Croppie/</a></p>
  
  <p>However, croppie does not seem to provide me with an easy solution to attach the cropped image to the standard html filehandler. So I decided to attach the image information and the image name to a hidden file element and send it along with my post request to my laravel instance. However, my problem is now that I want to use the StoreAs method, because it allows me to attach my image to a specific url which I can retrieve which I find very useful, when retrieving a big amount of images. </p>
  
  <p>The StoreAs() method in Laravel apparently only allows to use an object of type UploadedFile, which is based on the Symfony\Component\HttpFoundation\File\UploadedFile class. This UploadedFile object apparently is sent automatically along with the file when using the filehandler in html.</p>
  
  <p>I have a base64 encoded image similar to this: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAgAElEQVR4nOy9d3RUZ5ruuyvnnJNyzpEgcg4mO+e23U7t3Hl6wu2ZOTPn3Dtn8unTTTAYMGBjbDAYCZRBApRIkkpSqZ
  and an image name.</p>
  
  <p>I found that I can create a UploadedFile object in Laravel myself but I struggle to understand how I have to create this UploadedFile and then use the StoreAs() method to link it to a generated url. </p>
  
  <p>I found this link here: <a href="https://stackoverflow.com/questions/25827765/laravel-file-path-to-uploadedfile-instance">Laravel - file path to UploadedFile instance</a>
  And this one here: <a href="https://gist.github.com/m241802/0b5d0a98318304ff08cf" rel="nofollow noreferrer">https://gist.github.com/m241802/0b5d0a98318304ff08cf</a></p>
  
  <p>But I still do not completely get how I can create an UploadedFile object out of the image I have and the image name. </p>
  
  <p>Does anyone have an idea how to accomplish this? Or even can suggest a more elegant solution to my problem?? Perhaps someone has a better solution as to how I can send an File object in the post request after having used the croppie library? </p>
  
  <p>Thanks in advance for any help!</p>