title: I.m Getting "Call to a member function getClientOriginalName() on null" when uploading image with axios in laravel blade
body: <p>Why I'm getting</p>
  <blockquote>
  <p>Call to a member function getClientOriginalName() on null</p>
  </blockquote>
  <p>when uploading an image as below.
  Request payload is looks like</p>
  <p>------WebKitFormBoundaryU2XJIVhmCHdi06EH</p>
  <p>Content-Disposition: form-data; name=&quot;image&quot;; filename=&quot;download (3).jfif&quot;
  Content-Type: image/jpeg</p>
  <p>------WebKitFormBoundaryU2XJIVhmCHdi06EH--</p>
  <p>in my blade file</p>
  <pre><code> &lt;form action=&quot;&quot; id=&quot;img_form&quot; method=&quot;POST&quot; enctype=&quot;multipart/form-data&quot; onchange=&quot;uploadImage()&quot;&gt;
      @csrf
      &lt;input type=&quot;file&quot; id=&quot;image&quot; name=&quot;image&quot; onchange=&quot;uploadImage()&quot;&gt;
  
   &lt;/form&gt;
  </code></pre>
  <p>Js Code</p>
  <pre><code>function uploadImage(event) {
          console.log('image');
          const formData = new FormData();
          const imagefile = document.querySelector('#image');
          formData.append(&quot;image&quot;, imagefile.files[0])
          // formData.append(&quot;image_2&quot;, imagefile.files[0]);
          console.log('formdata' +formData);
          axios.post('upload/image', formData, {
              headers: {
                  'Content-Type': imagefile.type
                  // 'Content-Type': 'multipart/form-data;charset=utf-8;boundary=' + Math.random().toString().substr(2)
              }
          }).then(response =&gt; {
              console.log('response' + response.data);
  
          });
      }
  </code></pre>
  <p>In My laravel Controller</p>
  <pre><code>public function uploadImage(Request $request){
  
      
      $file = $request-&gt;file('image');
  
      $name =  $file-&gt;getClientOriginalName().'-'.time() ;
      $filePath = 'images/' .  $name;
      Storage::disk('public')-&gt;put($filePath, file_get_contents($file));
  
      $get_url = Storage::disk('public')-&gt;url($filePath);
  
      return response()-&gt;json([
          'name' =&gt; $name,
          'url' =&gt; $get_url
      ]);
  }
  </code></pre>