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

FSO FileExists Issue in ASP? 1

Status
Not open for further replies.

TomSark

MIS
Oct 19, 2000
448
US
Hi,

What's wrong with this code? The FileExists method returns false, yet the file does exist and this works in a VB program running on the same server, but the asp page does not. Permissions are OK...

Thanks in advance, I've left out the rest of the VB Script code...

Dim fso
Dim myvar
Dim mystr

Set fso = server.CreateObject("Scripting.FileSystemObject")

mystr = "\\myserver\com\common\signatures\files\sig1.bmp"

myvar = (fso.FileExists(mystr))

Set fso = Nothing
Response.WRITE myvar Tom Davis
tdavis@sark.com
 
You should usually use server.mappath("../products/image.gif") to get the actual server path. It prevents path errors like this and returns the path that ASP really wants. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
I already tried to map a drive on the IIS server that references it. That didn't work either.

I am thinking that it has to do with permissions in that the IUSR_ account doesn't have the permission needed to access the file, but it doesn't seem to matter whether or not I set the security to allow anonymous or windows NT challenge response, and the NTFS permissions allow domain users for that share & directory.

So... here's a security question: In what order are things checked when all of your security check boxes are checked
(1) or (3) Anonymous
(2) Basic Authentication
(3) or (1) NT Challenge/Response ?

Thanks in advance... Tom Davis
tdavis@sark.com
 
I am trying to get the same idea to work..
I get this error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.

This is my code:
<%
pictureurl = &quot;itemimages/&quot; & numb & &quot;.jpg&quot;
if CheckFileExists(Server.MapPath(pictureurl)) then %>
<img src=&quot;<%=pictureurl%>&quot; border=1>
<% end if %>

Function CheckFileExists(sFileName)
Dim FileSystemObject
Set FileSystemObject = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
If (FileSystemObject.FileExists(sFileName)) Then
CheckFileExists = True
Else
CheckFileExists = False
End If
Set FileSystemObject = Nothing
End Function
 
FSO Object wont work across the Shares. To make it work you need a trick.
Code:
Set ws = CreateObject(&quot;WScript.Network&quot;)
ws.MapNetworkDrive &quot;Z:&quot;, &quot;\\myserver\com&quot;,false,ShareUser,SharePassword
  Set fso = server.CreateObject(&quot;Scripting.FileSystemObject&quot;) 
  mystr = &quot;Z:\common\signatures\files\sig1.bmp&quot;
  myvar = fso.FileExists(mystr)

ws.RemoveNetworkDrive &quot;Z:&quot;,true

________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top