How to know the type of file and size?

Hi all,
Wish you a Happy New Year to all.

In one of my page,
i asked user to upload the image by using browse button from the local system.
It is working fine.
but it uploads not only the image format, it accepts any type.
Now i want to check the type of the format and if it is any of image formats it will accept otherwise it will show an alert type of message.

And also, based on the image type, i want to put some limitations based on the memory…

How to do that…

Give me some help regarding this…

Thanking you…