Displaying Generic Images

Results 1 to 2 of 2

Thread: Displaying Generic Images

  1. #1
    Bill Ritz Guest

    Default Displaying Generic Images

    My question is about displaying images. I have a field with the image name stored in it. I call that image in my asp file. If the image is not there, it displays a red &#039x&#039 (obviously). How can I display a generic picture if it can&#039t find the file it is looking for? IE. Can asp look for a file and if the file size is ZERO, load generic.jpg or check to see if the file exists, then load it or load a generic if it can&#039t be found? Any help would be appreciated!<BR><BR>webmaster@mwgbeach.com

  2. #2
    Join Date
    Dec 1969

    Default RE: Displaying Generic Images

    &#062; Can asp look for a file and ...check to see if the file exists, <BR><BR>Sure! Just use the Scripting.FileSystemObject.FileExists method to test for its existence. It&#039s in the VBScript docs. If you don&#039t have the docs on your machine (and why not?) just go to http://msdn.microsoft.com/scripting and click on "VBScript" in the left panel and then "Documentation" and rummage around and you&#039ll find the docs for FileSystemObject.<BR><BR>NOTE: ASP does *NOT* "load" any image file! When you output <BR>&#060;IMG SRC="&#060;% = nameFromDB %&#062;"&#062;<BR>from ASP, what actually happens is that the text is sent to the browser. The browser notices the IMG tag. The browser makes a SEPARATE HTTP REQUEST back to the Web server to get the image file as a stream of bytes. Every IMG tag causes this, which is why even very tiny .jpg and .gif files can slow down page load dramatically, since each initiates a brand new transfer of data from the server to the browser, with all the really ugly HTTP overhead in *each* transfer.<BR>

Posting Permissions

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