PHP: Find total number of images having same name in a folder.

Posted by Muhammad Sajid on Stack Overflow See other posts from Stack Overflow or by Muhammad Sajid
Published on 2010-05-29T05:38:26Z Indexed on 2010/05/29 5:42 UTC
Read the original article Hit count: 189

Filed under:

Hi,

I am creating code to upload images in a folder using PHP, & before upload an image I check that if any image with same name already exists in the folder by using below syntax:

if (file_exists('profilephoto/' . 'frame.gif')) {
}

But actually I don't want to restrict the user to upload more images with same name & obviously it is impossible to save two images with same name , but there is a way to just find total number of images with same name & upload the next image with appending total number + 1 with image name.

Now I just want to know that using PHP how could we find total number of images having same name in a folder?

Thanks.

© Stack Overflow or respective owner

Related posts about php5