views:

16

answers:

1

Im using fpdf to output details about an employee and an image of the employee if one is found. I have it setup to get the employee id from user input then send that id to the fpdf where it pulls the employee data from the db and display it on the pdf. So far I have a few pictures and renamed them to the same id of the employee the pictures are of. so if employee id is 534 his picture is named 534.jpg. Everything is working so far but for the employees that I do not have a picture of yet the pdf will not load. So Im hoping someone call help me write a script that will check if that picture is in the folder and if not display a default picture. Here is a sample of the code:

Dim techpic2
techpic2 = eID &".jpg"



pdf.Image techpic2,90,38,27,0," "

Im hoping I can write a scipt something like

if techpic2 = Not Found THEN

techpic2 = "default.jpg";

But I am not sure how to check a folder for a file or the correct syntax, if anyone knows this I would really appreciate it.

A: 

Use FileExists:

Example which you can adapt :

dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists("c:\asp\image.jpg")=true then
  response.write("File c:\asp\image.jpg exists!")
else
  response.write("File c:\asp\image.jpg does not exist!")
end if
set fs=nothing
Edelcom
@Edelcom thank you very much, this is exactly what I needed I just tested it and now everything works perfect. Thanks again!
bluffo