1$image_name = $_FILES["inputname"]["name"];
2$allowed_extensions = array("png", "jpg", "jpeg");
3$image_extension = explode(".", $image_name);
4/*
5 *Explode returns array of words
6 *Explode Example:
7 explode(search_for, where to search for);
8 let imagine that the image named => myimage.png
9 expldoe funtion will search the word for '.' and explode it
10 from the example, explode will return array("myimage", "png")
11 Now we find our image extension, but it is in the array.
12 we use end() function that will return the last index in the array as a string
13*/
14$extension = end($image_extension); // which is png
15if(!in_array($extension, $allowed_extensions)){
16 echo "Please upload an image";
17}
18else{
19 echo "Allowed Image";
20}