php - Get an image extension from an uploaded file in Laravel -


i have been trying extension uploaded file, searching on google, got no results.

the file exists in path:

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

now, how can extension of file above?

using input fields can extension this:

input::file('thumb')->getclientoriginalextension(); 

thanks.

you can use pathinfo() function built php that:

$info = pathinfo(storage_path().'/uploads/categories/featured_image.jpg'); $ext = $info['extension']; 

or more concisely, can pass option get directly;

$ext = pathinfo(storage_path().'/uploads/categories/featured_image.jpg', pathinfo_extension); 

Comments

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -

javascript - How to change image src on success AJAX -