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

using server.mappath with FORM ACTION

Status
Not open for further replies.

Floodster

Technical User
Jan 28, 2005
204
0
0
Hi,
I have a form which works on my pc set up as a local server, however when i upload to the 'web' i have problems.
the form code is;
<form action= "gbproc.asp" method="POST" target="main_frame">

As I don't know the full datapath on the web server I thought I could use the server.mappath but when I try & insert this into the form it won't work.

for reference the file gbproc.asp is located in a subfolder called GB.
the link to GB.html which loads gbproc.asp is in the ROOT so I am assuming that it is looking for gbproc.asp in the ROOT
 
Just use a relative reference including the directory:

[tt]<form action= "./GB/gbproc.asp" method="POST" target="main_frame">[/tt]

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
You don't need to map the server local path for the action value - as long as the gbproc.asp file is in the same directory on the server as the file that this code is in it should work ok as per your example above.

If they are both in the same directory on the server and it still fails (without server.mappath) then you may want to provide us with some more details as to the error you are getting.

For relative urls (like gbproc.asp) the user agent(browser) will take the url path part of the current page and add the relative bit on the end:

e.g. when on this page:
http : //
with gbproc.asp in the action field would make the browser request this url:
http : //
If you Server.MapPath it, you will get something like this in the action field:

action="C:\
the browser will assume it is an absolute URL and try to retrieve it.. which wont work as the file will not be found.

hope that clarifies.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top