#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    Langley, BC Canada
    Posts
    35
    Rep Power
    14

    How to see if an image file exists


    I'm building some dynamic image links based on if the image file exists.

    How can I check 'if files exists' using asp or javascript?

    I've messed around some with FileSystemObject but so far no success.

    Thanks in advance for any suggestions.

    Heinz

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    17
    The FileSystemObject has a method called fileExists(). Use this to check. You may have to use the server method, server.mappath, to ensure that you are using the full path to the file.

    PHP Code:
    set fso server.createObject("Scripting.FileSystemObject")
    if 
    fso.fileExits(server.mappath("relative/file/path")) then 
       response
    .write "file exists" 
    else 
       
    response.write "file does not exist"
    end if 
  4. #3
  5. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    And you know I mean that.

IMN logo majestic logo threadwatch logo seochat tools logo