$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']); } }