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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileExists or not FileExists?

Status
Not open for further replies.

ralphonzo

Programmer
Apr 9, 2003
228
GB
Trying to feed RSS with images, which works fine except where there is no image whereupon I get this error message:

"Microsoft VBScript runtime error '800a01a8'
Object required: '[object]'
/hbk/news.asp, line 85"

Line 85 = "response.write "<img src='" & cnodes(j).NodeValue & "' alt='image (0," & j & ")' class='floatLeft' width='200' />""

So then I tried to see if the image FileExists and got:

"Server.MapPath() error 'ASP 0173 : 80004005'
Invalid Path Character
/hbk/news.asp, line 110
An invalid character was specified in the Path parameter for the MapPath method."

Line 110 = "if fs.FileExists(server.mappath(fe)) = true then"

I then tried as many escape characters as I thought might be needed in the string: " and cut off everything after and including the question mark following the file extension, but I still get the same invalid character crap. Here's the offending code block:

Code:
set fs=Server.CreateObject("Scripting.FileSystemObject")
imgorg = ""
imgorg = cnodes(j).NodeValue
imgvalue = ""
looper = 0
response.write imgorg
do while int(looper) < int(len(imgorg))
if mid(imgorg,looper+1, 1) = ":" then
imgvalue = imgvalue + chr(58) 
elseif mid(imgorg,looper+1, 1) = "?" then
looper = len(imgorg)
elseif mid(imgorg,looper+1, 1) = "&" then
imgvalue = imgvalue + chr(38) 
elseif mid(imgorg,looper+1, 1) = "/" then
imgvalue = imgvalue + chr(47) 
elseif mid(imgorg,looper+1, 1) = "." then
imgvalue = imgvalue + chr(46) 
elseif mid(imgorg,looper+1, 1) = "=" then
imgvalue = imgvalue + chr(61) 
else
imgvalue = imgvalue + mid(imgorg,looper+1, 1)
end if
response.write imgvalue&" - '"&mid(imgorg,looper+1, 1)&"'<br>"
looper = looper+1
loop
response.write "<br>>>"&imgvalue&"<br>"
fe = imgvalue
if fs.FileExists(server.mappath(fe)) = true then
response.write "<img src='" & cnodes(j).NodeValue & "' alt='image (0," & j & ")' class='floatLeft' width='200' />"
end if

I hope it's something dumb that I'm (not) doing. Anybody spot the error?
 
What does server.mappath(fe) return? The url or the local path on the server?

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Thanks for getting back. I tried

Code:
response.write "<br>>>"&server.mappath(fe)

and I'm afraid this line returned:

Code:
Server.MapPath() error 'ASP 0171 : 80004005'
Missing Path
/hbk/news.asp, line 108
The Path parameter must be specified for the MapPath method.

Does that make any sense?
 
What is the result of response.write "<br>>>"&imgvalue&"<br>" ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sure, it makes sense. It's saying "Missing Path", which begs the question what does server.mappath(fe) return? Better yet, what does imgvalue contain? Furthermore, what does imgorg contain?

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
It doesn't get as far as displaying imgvalue as it falls over at this line:

Code:
imgorg = cnodes(j).NodeValue

I know the problem lies with themissing image. I just need to know how to ignore it. I just can't seem to be able to check to see if an object is there or not.
 
What about a On Error Resume Next statement and test the Err.number property ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top