Using GetAbsolutePathName with File Input

G

Grayscale

Hello,

I have two asp pages and try to get the folder & file name which is
selected on the first page but when I select any file and press submit,
it shows the folder as "C:\Windows\System32\-filename-" but I want to
show actual folder. When I use "text" as the input type, there is no
problem. Also I tried to use Request. Form method only but it shows
only the file name not the directory. So I decided to use
GetAbsolutePathName too. But it doesn't work for me. I'll be glad if
you help me to solve this problem.

--name1.asp--
<html>
<head>
<body>
<form action="name2.asp"
method="post">
Dosya ismi:
<input type="file" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</head>
</html>


--name2.asp--
<html>
<head>
<body>
<%
dim fs, path, name
set fs=Server.CreateObject("Scripting.FileSystemObject")
name=Request.Form("fname")
path=fs.GetAbsolutePathName(name)
response.write(path)
%>
</body>
</head>
</html>
 
M

Mike Brind

Grayscale said:
Hello,

I have two asp pages and try to get the folder & file name which is
selected on the first page but when I select any file and press submit,
it shows the folder as "C:\Windows\System32\-filename-" but I want to
show actual folder. When I use "text" as the input type, there is no
problem. Also I tried to use Request. Form method only but it shows
only the file name not the directory. So I decided to use
GetAbsolutePathName too. But it doesn't work for me. I'll be glad if
you help me to solve this problem.

--name1.asp--
<html>
<head>
<body>
<form action="name2.asp"
method="post">
Dosya ismi:
<input type="file" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</head>
</html>


--name2.asp--
<html>
<head>
<body>
<%
dim fs, path, name
set fs=Server.CreateObject("Scripting.FileSystemObject")
name=Request.Form("fname")
path=fs.GetAbsolutePathName(name)
response.write(path)
%>
</body>
</head>
</html>

What are you trying to do? Upload a file and find where you have
uploaded it to? Or find the location of a file on a client machine?
Either way, you ain't going to get it done with the scripts you have
here. There is no upload code in name2.asp, so the file never gets
uploaded and therefore does not exist. And if you are trying to find
out where the file is on the client machine, you can't. ASP doesn't
allow you to do that.

Or are you trying to do something else?
 
G

Grayscale

I don't try to upload any file, just try to learn the path and name of
selected file. I need the path to use it as a variable to specify the
text file object. For example:

Set objTextFile = objFSO.OpenTextFile
("c:\Inetpub\wwwroot\record\data.txt", ForReading)

I'll need to select other text files to change the specified file and
don't want to change the code each time I execute it.

So I need something like this:
Set objTextFile = objFSO.OpenTextFile (-#-variable-#-, ForReading)

The variable will be equal to selected file's path.
 
B

Bob Barrows [MVP]

Grayscale said:
I don't try to upload any file, just try to learn the path and name of
selected file. I need the path to use it as a variable to specify the
text file object. For example:

Set objTextFile = objFSO.OpenTextFile
("c:\Inetpub\wwwroot\record\data.txt", ForReading)

I'll need to select other text files to change the specified file and
don't want to change the code each time I execute it.

So I need something like this:
Set objTextFile = objFSO.OpenTextFile (-#-variable-#-, ForReading)

The variable will be equal to selected file's path.

Use Server.MapPath
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top