logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA
Irish Culture


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Handling Missing Graphic Files


It's common to use ASP to display graphic images on the fly. You can have your code check to make sure the graphic file is actually there - and show a default image if it is missing for some reason.

The command you're going to use here is FileExists - the command checks to see if the file you specify actually exists on the server. You can then do different processing based on whether or not you find the specified file.

Let's say you have an inventory system where all of your products are given sequential numbers - from P1 to P1000 and so on. Your image files are named to match, so P1.jpg, P2.jpg, etc. This normally makes it very easy for you to automatically show the image that goes with a given product.

If you have to remove an image for some reason, the following code will show a default image until you get around to putting a new proper image into the directory.

<%
dim picFSO
set picFSO = createobject("Scripting.FileSystemObject")
PicPath = "/images/products/P" & ProductID & ".jpg"
PicFullPath = Server.MapPath(PicPath)
if picFSO.FileExists(PicFullPath) THEN
FoundImage = TRUE
else
FoundImage = FALSE
end if
%>

Once you've got that FoundImage set properly, you can now do whatever if-then statements you like. You can use a standard IMG SRC= to display that proper PicPath entry if FoundImage is true, or show another default entry if the FoundImage is false.
Add Handling+Missing+Graphic+Files to Twitter Add Handling+Missing+Graphic+Files to Facebook Add Handling+Missing+Graphic+Files to MySpace Add Handling+Missing+Graphic+Files to Del.icio.us Digg Handling+Missing+Graphic+Files Add Handling+Missing+Graphic+Files to Yahoo My Web Add Handling+Missing+Graphic+Files to Google Bookmarks Add Handling+Missing+Graphic+Files to Stumbleupon Add Handling+Missing+Graphic+Files to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor