Image problems

Results 1 to 3 of 3

Thread: Image problems

  1. #1
    Shannon Klein Guest

    Default Image problems

    I cannot guarantee that certain images will be in a directory when the page loads. How can I replace these images with a "notavailable.jpg image if that picture does not exist. I do not want my users to see the dreaded red X where the image should be.

  2. #2
    Steve Cimino Guest

    Default RE: Image problems

    I&#039ve never done this, but you could try the FSO.<BR><BR>If fso.FileExists(yourimagepath) Then<BR> Response.write "&#060;IMG SRC=images/" & yourimagename & "&#062;"<BR>Else<BR> Response.write "&#060;IMG SRC=images/notavailable.jpg"&#062;<BR>End If<BR><BR><BR>You&#039ll need to know the image name (should be easy) and then set the absolute path to the image with yourimagepath -- something like:<BR><BR>yourimagename = "mypicture.jpg"<BR>yourimagepath = "C:mypictures\" & yourimagename

  3. #3
    Join Date
    Dec 1969

    Default Don't forget to use the PHYSICAL path

    The fso commands require that you use physical, not virtual, path data. You can get this for a particular file on your website using the Server.MapInfo command as follows:<BR><BR>strSearchPath = ("/images/whatever.jpg")<BR><BR>Then just do the fso stuff. For example:<BR><BR>Set fso = Server.CreateObject("Scripting.FileSystemObject")< BR>Set f = fso.FileExists(path)<BR><BR>If that "whatever" file that you mapped above is actually named dynamically (for example, using a SQL search), then you might want to create a mapping string before you do anything else. For example:<BR><BR>MyFile = "/images/" & rs("ImageURL") & ".JPG"<BR><BR>Then:<BR><BR>strSearchPath = (MyFile)<BR>Etc.

Posting Permissions

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