title: How to get extension and temp path in laravel
body: <p>I have a file upload function in laravel. The user gets to select multiple files so I need to separate the images file and the documents so I could compress the images. Therefore I need to get the extensions but it just doesn't work for me. I'm using Laravel 7.3 and these are the codes I tried:</p>
  
  <p><code>$request-&gt;files-&gt;getClientOriginalExtension();</code></p>
  
  <p><code>$request-&gt;files-&gt;extension();</code></p>
  
  <p>I also tried to get the temp path using:</p>
  
  <p><code>$request-&gt;files-&gt;getPathName()</code></p>
  
  <p>This is the array returned by <code>$request-&gt;files</code>:</p>
  
  <pre><code>Symfony\Component\HttpFoundation\FileBag Object
  (
      [parameters:protected] =&gt; Array
          (
              [files] =&gt; Array
                  (
                      [0] =&gt; Symfony\Component\HttpFoundation\File\UploadedFile Object
                          (
                              [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 
                              [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; Annotation 2020-02-26 084917.png
                              [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; image/png
                              [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 0
                              [pathName:SplFileInfo:private] =&gt; C:\xampp\tmp\php6AA9.tmp
                              [fileName:SplFileInfo:private] =&gt; php6AA9.tmp
                          )
                  )
          )
  )
  </code></pre>
  
  <p>I also want to get the value from <code>[pathName:SplFileInfo:private]</code> so I could compress the image but all the codes I stated that I tried above return the same error:</p>
  
  <blockquote>
    <p>message: "Call to undefined method
    Symfony\Component\HttpFoundation\FileBag::getClientOriginalExtension()"</p>
  </blockquote>
  
  <p>Edit:</p>
  
  <p>I also tried </p>
  
  <pre><code>foreach($request-&gt;files as $file) {
     foreach ($file as $in) {
      print_r($in-&gt;extension());
     }
  }
  </code></pre>
  
  <p>But would give an error <code>Call to undefined method Symfony\Component\HttpFoundation\File\UploadedFile::extension()</code></p>