473,562 Members | 2,613 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

server.mappath( ) parent

How to use server.mappath( ) parent folder correctly:

Server.MapPath( "../test.asp")

Thank you for the hint.

May 3 '07 #1
4 7171
MapPath
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash
(\), the MapPath method returns a path as if Path is a full virtual path. If Path doesn't start with a slash, the MapPath method
returns a path relative to the directory of the .asp file being processed.
Remarks
The MapPath method does not support relative path syntax (.) or (..). For example, the following relative path, ../MyDir/MyFile.txt,
returns an error.

The MapPath method does not check whether the path it returns is valid or exists on the server.

Because the MapPath method maps a path regardless of whether the specified directories currently exist, you can use the MapPath
method to map a path to a physical directory structure, and then pass that path to a component that creates the specified directory
or file on the server.



<vu******@gmail .comwrote in message news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
How to use server.mappath( ) parent folder correctly:

Server.MapPath( "../test.asp")

Thank you for the hint.

May 3 '07 #2
On May 3, 1:35 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
comwrote:
MapPath
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash
(\), the MapPath method returns a path as if Path is a full virtual path. If Path doesn't start with a slash, the MapPath method
returns a path relative to the directory of the .asp file being processed.
Remarks
The MapPath method does not support relative path syntax (.) or (..). For example, the following relative path, ../MyDir/MyFile.txt,
returns an error.

The MapPath method does not check whether the path it returns is valid or exists on the server.

Because the MapPath method maps a path regardless of whether the specified directories currently exist, you can use the MapPath
method to map a path to a physical directory structure, and then pass that path to a component that creates the specified directory
or file on the server.

<vunet...@gmail .comwrote in messagenews:11* *************** ******@q75g2000 hsh.googlegroup s.com...
How to use server.mappath( ) parent folder correctly:
Server.MapPath( "../test.asp")
Thank you for the hint.
so what would be a reasonlabe solution to check the existence of
temp.asp inside of file1.asp:

www.mysite.com/filder2/file1.asp
www.mysite.com/temp/temp/temp.asp

May 3 '07 #3
vu******@gmail. com wrote on 3 May 2007 12:20:44 -0700:
On May 3, 1:35 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com>wrote:
>MapPath
The MapPath method maps the specified relative or virtual path to the
correspondin g physical directory on the server.

Syntax
Server.MapPath ( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory.
If Path starts with either a forward (/) or backward slash (\), the
MapPath method returns a path as if Path is a full virtual path. If Path
doesn't start with a slash, the MapPath method returns a path relative to
the directory of the .asp file being processed. Remarks The MapPath
method does not support relative path syntax (.) or (..). For example,
the following relative path, ../MyDir/MyFile.txt, returns an error.

The MapPath method does not check whether the path it returns is valid or
exists on the server.

Because the MapPath method maps a path regardless of whether the
specified directories currently exist, you can use the MapPath method to
map a path to a physical directory structure, and then pass that path to
a component that creates the specified directory or file on the server.

<vunet...@gmai l.comwrote in messagenews:11* *************** ******@q75g2000 hsh.googlegroup s.com...
>>How to use server.mappath( ) parent folder correctly:
>>Server.MapPat h("../test.asp")
>>Thank you for the hint.

so what would be a reasonlabe solution to check the existence of
temp.asp inside of file1.asp:

www.mysite.com/filder2/file1.asp
www.mysite.com/temp/temp/temp.asp
Try

sFile = Server.MapPath( "/temp/temp/temp.asp")

Set oFS = Server.CreateOb ject("Scripting .FileSystemObje ct")
If oFS.FileExists( sFile) Then
'file exists
End If
Set oFS = Nothing

Of course, this isn't a perfect solution - for instance, there may be an
ISAPI pre-processor that handles incoming requests and redirects them
elsewhere based on the path, so the file /temp/temp/temp.asp might not even
reside on the same server, or in the same path structure, as
/filder2/file1.asp. Assuming a "normal" configuration, this should work
though.

Dan
May 4 '07 #4
On May 4, 7:40 am, "Daniel Crichton" <msn...@worldof spack.comwrote:
vunet...@gmail. com wrote on 3 May 2007 12:20:44 -0700:
On May 3, 1:35 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com>wrote:
MapPath
The MapPath method maps the specified relative or virtual path to the
corresponding physical directory on the server.
Syntax
Server.MapPath( Path )
Parameters
Path
Specifies the relative or virtual path to map to a physical directory.
If Path starts with either a forward (/) or backward slash (\), the
MapPath method returns a path as if Path is a full virtual path. If Path
doesn't start with a slash, the MapPath method returns a path relative to
the directory of the .asp file being processed. Remarks The MapPath
method does not support relative path syntax (.) or (..). For example,
the following relative path, ../MyDir/MyFile.txt, returns an error.
The MapPath method does not check whether the path it returns is valid or
exists on the server.
Because the MapPath method maps a path regardless of whether the
specified directories currently exist, you can use the MapPath method to
map a path to a physical directory structure, and then pass that path to
a component that creates the specified directory or file on the server.
<vunet...@gmail .comwrote in messagenews:11* *************** ******@q75g2000 hsh.googlegroup s.com...
How to use server.mappath( ) parent folder correctly:
>Server.MapPath ("../test.asp")
>Thank you for the hint.
so what would be a reasonlabe solution to check the existence of
temp.asp inside of file1.asp:
www.mysite.com/filder2/file1.asp
www.mysite.com/temp/temp/temp.asp

Try

sFile = Server.MapPath( "/temp/temp/temp.asp")

Set oFS = Server.CreateOb ject("Scripting .FileSystemObje ct")
If oFS.FileExists( sFile) Then
'file exists
End If
Set oFS = Nothing

Of course, this isn't a perfect solution - for instance, there may be an
ISAPI pre-processor that handles incoming requests and redirects them
elsewhere based on the path, so the file /temp/temp/temp.asp might not even
reside on the same server, or in the same path structure, as
/filder2/file1.asp. Assuming a "normal" configuration, this should work
though.

Dan
let me try. thanks a lot

May 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
14304
by: John Rebbeck | last post by:
I've got the directory f:\Company\Product set as web shared so it's got a virtual directory in the default web site on my test server's IIS. If I try to use Server.MapPath in that site it returns a path within c:\Inetpub\wwwroot rather than the real path. Can anyone please tell me why this isn't working? Regards, John
24
7402
by: Lovely Angel | last post by:
Dear Friends Hope you doing great. I have recently shifted to a webhost which is Using Windows 2003 and IIS 6. Now my application was working fine earlier but now I am facing this problem Server.MapPath() error 'ASP 0175 : 80004005' Disallowed Path Characters /backend/_add_two.asp, line 103
7
3674
by: Elie Grouchko | last post by:
Hi I am running exactly the same ASP code on IIS 5.0 and IIS 6.0 I am calling Server.MapPath(), the parameter is a virtual path that includes a reference to a parent path ("Root/Files/../Config/"). 'Config' is a virtual directory under 'Root' which is also a virtual directory. 'Files' is a normal folder. Under IIS 5.0, the path is...
7
2350
by: laura | last post by:
I'm trying to understand fully Server.MapPath. I am writing an intranet for a small company and want to be able to put some files accessible to all, hyperlinked from the intranet and therefore, outside of the website area - the idea being that I want staff to be able to copy files into folders that can be accessed by hyperlinks on the intranet...
4
1785
by: Mark Horrocks | last post by:
Hi, Whilst trying to solve another problem (see my post yesterday please!) I have come across something strange. I created an ASP version and an ASPX version of the same code, and ran it in the same folder, ie: http://x.y.z/code/test.asp and http://x.y.z/code/test.aspx I use code in front as i can't get code behind working on my server (see...
6
1596
by: darrel | last post by:
I have some functions that are reading/writing to the file system. As such, they use server.mapPath a lot to navigate it all. Since I'm using these functions numerous times throughout my application, I thought I'd move these into their own .vb class file and reference them that way. The catch is when moving these scripts over,...
4
1648
by: jamting | last post by:
Since i reinstalled windows server, i've had a strange behaviour in server.mappath. for instance this file: test.asp: <% response.write server.mappath(".") & "<br>" response.write server.mappath("..") %>
3
15053
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named Hello.aspx resides in C:\Inetpub\wwwroot\MyFolder, the output of both Response.Write(Server.MapPath("Hello.aspx")) & ...
3
4120
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have one line code in my program, occasionaly I will receive the following error: "The Path parameter for the MapPath method did not correspond to a known path" Path=Server.MapPath(sCertPath & "\" & order_id & ".pdf") I am wondering what is happening since every time I check my error log, the
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7940
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6228
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5198
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
907
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.