By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,484 Members | 1,811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,484 IT Pros & Developers. It's quick & easy.

Finding the 'root' level?

P: n/a
Hi all,

I've written a small form handler script which should work for 'all' (term
used loosely) forms...

It will email the company, send courtesy emails to the form filler and save
data to a text file - all with various options made easy by changing hidden
tags in the form.

One minor problem I've come across is that I need to be able to write to a
specific directory on the server.

So lets say I allow a hidden tag for the owner of the server to enter the
name of the directory they want to write to, lets call it 'data'.

When I use the Server.Mappath('data') in this scenario, it looks within the
same directory, as a result it does not find the directory, and then my
script creates one.

The actualy directory (in the current case) is say one level above (../
etc), but I dont know that that is always going to be the case.

I'd rather not have to put the script in the root level of the web for this
to always work, as for frontpage users for example they may have subwebs and
so on, but the data folder could well be in the main root directory.

So, how can I ensure that using the Server.Mappath('data') find the 'data'
folder at the root level.

I appreciate on my setup here I could simply enter the full path, ie,
E:\webs\webdev\some-client\data but I need 'joe public' to be able to enter
just the name of the directory (or use the default of 'form-data' or
something), and have it written to the correct place.

Anybody got any ideas/suggestions?

Thanks in advance for any help,

Regards

Robb Meade
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Have you tried something like this:

set fso = server.createobject("Scripting.FileSystemObject")
if fso.folderExists(server.mappath("/") & "data") then
' folder exists in root!
end if
set fso = nothing
Not sure if it needs to be "\data" -- I always forget the behavior of
server.mappath. I could have tested it in the time it took me to state
that, but I'm lazy today...


"Robb Meade" <ro********@NOSPAMkingswoodweb.net> wrote in message
news:NZ*********************@news-text.cableinet.net...
Hi all,

I've written a small form handler script which should work for 'all' (term
used loosely) forms...

It will email the company, send courtesy emails to the form filler and save data to a text file - all with various options made easy by changing hidden tags in the form.

One minor problem I've come across is that I need to be able to write to a
specific directory on the server.

So lets say I allow a hidden tag for the owner of the server to enter the
name of the directory they want to write to, lets call it 'data'.

When I use the Server.Mappath('data') in this scenario, it looks within the same directory, as a result it does not find the directory, and then my
script creates one.

The actualy directory (in the current case) is say one level above (../
etc), but I dont know that that is always going to be the case.

I'd rather not have to put the script in the root level of the web for this to always work, as for frontpage users for example they may have subwebs and so on, but the data folder could well be in the main root directory.

So, how can I ensure that using the Server.Mappath('data') find the 'data'
folder at the root level.

I appreciate on my setup here I could simply enter the full path, ie,
E:\webs\webdev\some-client\data but I need 'joe public' to be able to enter just the name of the directory (or use the default of 'form-data' or
something), and have it written to the correct place.

Anybody got any ideas/suggestions?

Thanks in advance for any help,

Regards

Robb Meade

Jul 19 '05 #2

P: n/a
Doesn't Server.MapPath("\Data\File.txt") return relative to the root?
What happens if your users enter the same name? Say "Data"?

"Robb Meade" <ro********@NOSPAMkingswoodweb.net> wrote in message
news:NZ*********************@news-text.cableinet.net...
Hi all,

I've written a small form handler script which should work for 'all' (term
used loosely) forms...

It will email the company, send courtesy emails to the form filler and save data to a text file - all with various options made easy by changing hidden tags in the form.

One minor problem I've come across is that I need to be able to write to a
specific directory on the server.

So lets say I allow a hidden tag for the owner of the server to enter the
name of the directory they want to write to, lets call it 'data'.

When I use the Server.Mappath('data') in this scenario, it looks within the same directory, as a result it does not find the directory, and then my
script creates one.

The actualy directory (in the current case) is say one level above (../
etc), but I dont know that that is always going to be the case.

I'd rather not have to put the script in the root level of the web for this to always work, as for frontpage users for example they may have subwebs and so on, but the data folder could well be in the main root directory.

So, how can I ensure that using the Server.Mappath('data') find the 'data'
folder at the root level.

I appreciate on my setup here I could simply enter the full path, ie,
E:\webs\webdev\some-client\data but I need 'joe public' to be able to enter just the name of the directory (or use the default of 'form-data' or
something), and have it written to the correct place.

Anybody got any ideas/suggestions?

Thanks in advance for any help,

Regards

Robb Meade

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.