PHP: Explode file extension | Malaysia Mari


 //example: basename($_FILES['file']['name'][$i] = angry_birds.jpg

$extension = explode(".", basename($_FILES['file']['name'][$i]));
$getExtension = count($extension) -1;
$extension = strtolower($extension[$getExtension]);

if($extension != "jpg" && $extension != "jpeg")
{
echo "only .jpg or .jpeg file";
}
echo $extension;


The output:
-------------------------
jpg
-------------------------

Full code will publish later. thanks


POSTED BY juong

Popular Posts

.

Back to Top