I am getting a problem to check wheather image is png,gif,jpg,jpeg. i tried using getimagesize(path to file) but it needs full path of image as i just have only image name that is image1.jpg. I want to check file type that is png,gif,jpg,jpeg before uploading it. I want a code to check type before uploading it to the directory. getimagesize(path to file) gives me waring that Failed to open stream becaus efile is not in directory, it is not uplaoded yet. I didnt find any thing that works for me. Can anybody here help me out of this problem. Here is my code:
list(image_width, image_height, image_type) = getimagesize("image1.jpg");
switch ($source_image_type)
{
case IMAGETYPE_GIF:
//some code here
break;
case IMAGETYPE_JPEG:
//some code here
break;
case IMAGETYPE_PNG:
//some code here
break;
}
This code gives me warning that Failed to open stream.