Check Image File Type & Size In PHP

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email
$allowedFileTypes = [
	'image/jpg',
	'image/jpeg',
	'image/png',
];

if( $_FILES['photo'] ){
	if( in_array($_FILES['photo']['type'], $allowedFileTypes)  && $_FILES['photo']['size']<1*1024*1024 ){
		move_uploaded_file($_FILES['photo']['tmp_name'],"uploads/images/".$_FILES['photo']['name']);
	}
}
Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert