Check Image File Type & Size In PHP

Share Now

$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']);
	}
}
Picture of Nahid Mahamud

Nahid Mahamud

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