469,580 Members | 2,007 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,580 developers. It's quick & easy.

Cannot access remote file from mapped drive

I want to access files from a remote server so I mapped it in my
server under z:\ for \\myserver\web\mysite\images\
I added this UNC path to my IIS virtual directory and name it as
"upload"
but I still cannot use any FSO to read it. Here is my code:

<%
Dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject ")

'Method one- NOT exist
if fs.FileExists("\\myserver\web\mysite\images\xxx.gi f")=true then
response.write("File exists!")
else
response.write("File NOT exist!")
end if

'Method two - NOT exist as well
if fs.FileExists("Z:\xxx.gif")=true then
response.write("File exists!")
else
response.write("File NOT exist!")
end if

%>

But if i run this html on where my asp is located, it can read this
file -
<img src='../upload/xxx.gif' >

I tried to use server.MapPath("../upload/") but i got this result
D:\Web\sys\upload
While my asp file is located in D:\web\sys
the problem is that there's no physical drive under D:\
I really have no clue here.
All I want to do is to check if a file exists on \\myserver\web\mysite
\images\
If yes then I am going to delete it.. that's why I need to use FSO.

Anyone has ideas?

Oct 26 '07 #1
1 8627
<ta********@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
I want to access files from a remote server so I mapped it in my
server under z:\ for \\myserver\web\mysite\images\
I added this UNC path to my IIS virtual directory and name it as
"upload"
but I still cannot use any FSO to read it. Here is my code:

<%
Dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject ")

'Method one- NOT exist
if fs.FileExists("\\myserver\web\mysite\images\xxx.gi f")=true then
response.write("File exists!")
else
response.write("File NOT exist!")
end if

'Method two - NOT exist as well
if fs.FileExists("Z:\xxx.gif")=true then
response.write("File exists!")
else
response.write("File NOT exist!")
end if

%>

But if i run this html on where my asp is located, it can read this
file -
<img src='../upload/xxx.gif' >

I tried to use server.MapPath("../upload/") but i got this result
D:\Web\sys\upload
While my asp file is located in D:\web\sys
the problem is that there's no physical drive under D:\
I really have no clue here.
All I want to do is to check if a file exists on \\myserver\web\mysite
\images\
If yes then I am going to delete it.. that's why I need to use FSO.

Anyone has ideas?
The problem is that the file system object knows nothing about IIS or ASP.
Therefore the fact that you have created and virtual directory is
meaningless.

Mapped drives are a user oriented construct. Two different users can could
log on a two different times and each can get their own set of mapped
drives. When no one is logged in there are no mapped drives. Its probably
not as simplistic as that but its not good to rely on mapped drives and you
still need the appropriate priviledges to access the content.

Hence the FSO will attempt to access the share under the IUSR_<machinename>
security token which won't have the appropriate priviledges.

You need the ASP that is using the file system object under a user account
that does have access.

One approach would be to change the anonymous user on the ASP file to a user
that has access.

However you need to be careful that this user only has read access to the
ASP file and read/write to the folder you want to modify. You need to be
sure that a malicuous formation of the URL can't go ahead and delete things
you wouldn't want deleting.
--
Anthony Jones - MVP ASP/ASP.NET
Oct 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Mike McIntyre [MVP] | last post: by
3 posts views Thread by James N | last post: by
2 posts views Thread by Peter O'Reilly | last post: by
5 posts views Thread by =?Utf-8?B?SmVycnkgQw==?= | last post: by
4 posts views Thread by vbshanes | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.