Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder student's Avatar
    Join Date
    Jan 2007
    Posts
    129
    Thanks
    13
    Thanked 0 Times in 0 Posts

    how to check if an image is present in the folder?

    hello,
    I have a problem and i will explain it using an example:
    my site is http://website.com
    i would like to check using PHP if an image picture.jpg exists in a folder in my site. http://website/images/
    if it is present, i would like to do { something }
    otherwise i would like to do { something else }

    I have tried to find if the image exists or not using fopen,
    it worked well if the image existed. but if the image is not present, it is giving an error message.

    how can i do it?
    thank you very much for all replies.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You can use the is_file() function.

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Can also use file_exists()


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •