Get an image extension from an uploaded file in La

2020-02-08 23:39发布

I have been trying to get the extension from an uploaded file, searching on google, I got no results.

The file already exists in a path:

\Storage::get('/uploads/categories/featured_image.jpg);

Now, How can I get the extension of this file above?

Using input fields I can get the extension like this:

Input::file('thumb')->getClientOriginalExtension();

Thanks.

7条回答
Animai°情兽
2楼-- · 2020-02-09 00:12
 //working code from laravel 5.2

 public function store(Request $request)
 {
          $file = $request->file('file');
            if($file)
            {
                    $extension =  $file->clientExtension();
            }
            echo $extension;
 }
查看更多
登录 后发表回答