Find file extension using php
Find file extension using php is very simple, the extension used to validation in php,
The below example is very useful to all.
PHP File
$extension = getExtension($_FILES['img_pics']['name']);
echo $extension
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
HTML File
<input name="img_pics" type="FILE" id="img_pics" value="Browse..." >
If you are going to upload JPG image The Output is : .jpg