Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    asp page... how to controll if image not existis

    How to controll if ObjRS("MATRICOLA") & ".jpg not existis in dir IMMAGINI
    i have insert

    'if Not fso.FileExists(pic_file) then
    'pic_file = "./Immagini/99999.jpg"
    'end if


    but not work!




    <%
    dim pic_file
    dim fso
    set fso = Server.CreateObject("Scripting.FileSystemObject")
    pic_file = "./Immagini/" & ObjRS("MATRICOLA") & ".jpg"
    'if Not fso.FileExists(pic_file) then
    'pic_file = "./Immagini/99999.jpg"
    'end if
    set fso = nothing
    'response.write(pic_file)
    %>

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: asp page... how to controll if image not exist

    The easiest answer is make sure that is not the case. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    Have a look at this link It shows other methods such as placing text there instead of an alternative image.
    Jerry

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: asp page... how to controll if image not existis

    Sal,

    You are very close! Try wrapping the pic_file name with Server.MapPath() each time you use the File.Exists method. It's looking for an absolute path (like C:Inepubwwwrootyoursiteimagesimagename.jpg) rather than a relative web path (images/imagename.jpg).

    One of the lines would read:

    If Not fso.FileExists(Server.MapPath(pic_file)) Then

    Hope this helps... Ciao!

Posting Permissions

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