filenames - PHP - Get file extension (image) without knowing it -


how can extension of image file without knowing is? have tried using glob, below, returns error: "array notice: undefined offset: 0"

$path=baseurl."content/images/profile_images/".$imagename; $results= glob($path.'.*');  $filename = $results[0]; echo $filename; 

your glob bad , it's returning empty array, hence error. it's not regular expression, it's shell expansion , * wildcard. try match filename begins .. ie. .htaccess.

if want match file use: glob($path.'*')

if want match file period in it: glob($path.'*.*')


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -