Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show picture if it exists but don't show broken link if not

Status
Not open for further replies.

bassguy

Programmer
Jun 21, 2001
336
US
Hi, I am trying to show an image dynamically in a table. the problem is that some of the images are .jpg some are .gif I am trying to see if the file exists as a jpg and then show it if it exists. if it does not exists I do not want the broken link box to come up....I Think I need to use FileSystemObject and FileExists but do not know how...any ideas??

bassguy

 
yes u r right.u must use filesystemobject.
here i send a program to find out the file type whether it is "gif" or "jpg"

set objfso=server.CreateObject("Scripting.FileSystemObject")
set objdrivec = objfso.GetDrive("C:")
set objroot= objdrivec.RootFolder

For each objFile in objroot.Files
dim extention
dim filename
filename=mid(objFile.Name,1,instrrev(objFile.Name,".",len(objFile.Name))-1)
extention=mid(objFile.Name,instrrev(objFile.Name,".",len(objFile.Name))+1,4)
'Response.Write(objFile.Name & &quot;<br>&quot;)
if lcase(extention)=&quot;gif&quot; or lcase(extention)=&quot;jpg&quot; then
Response.Write(&quot;File name:&quot; & objFile.Name&&quot;<br>&quot; )
end if
if lcase(filename)=&quot;leafbg&quot; and lcase(extention)=&quot;jpg&quot; then
Response.Write &quot;JPEG FILE&quot; & &quot;<br>&quot;
end if
next

i hope this may help u to solve the problem
with regards
webspy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top