<?php
$format = "gambar.jpg";
$pecah = explode(".",$format);
$ektensi = $pecah[1];
if($ektensi == "jpg"){
echo "berhasil";
}else{
echo "gagal";
}
?>
<?php
$pictures = array('image/jpg','image/jpeg','image/gif','image/png');
if(isset($_FILES['file'])){
if(in_array($_FILES['file']['type'],$pictures) && getimagesize($_FILES['file']['tmp_name'])){
//upload file
}else{
echo 'file bukan gambar';
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file"/>
<input type="submit" value="submit"/>
</form>