473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using GetAbsolutePathName with File Input

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>

Apr 4 '06 #1
3 2044

Grayscale wrote:
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?

--
Mike Brind

Apr 4 '06 #2
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.

Apr 4 '06 #3
Grayscale wrote:
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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 4 '06 #4

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

Similar topics

2
by: Jim Witte | last post by:
Hi, How do I set a file input element? If it's a text input, I can set the value property. But this doesn't work with file inputs. And no, I can't change it - I'm writing a script to...
2
by: Mongoose | last post by:
Hi all, We use <input type="file" name="FILEFILENAME" value=""> to get file input dialogs. My questions are: (1) Is it possible to add a bunch of file filters to the opening dialog box?...
7
by: garthb | last post by:
Hello, In Mozilla (Firefox 1.0.7) I can cloneNode a file input element that has a selected file value and appendChild it to another form without a problem. IE 6 loses the selected file value....
4
by: Robin | last post by:
On an ASP.Net page that has viewstate enabled. How do you enable viewstate for a server side file input control? Currently I have in the HTML view. <INPUT id="myID" type="file" name="myID"...
6
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
3
by: masterofzen | last post by:
Hi, everybody, Got a question that's completely perplexing me. I'm developing a site that uses a universal (or "star") selector on a global level, for many different pages. The star selector...
3
by: John Williams | last post by:
I'm writing a stagenography program to experiment with how it works. The algorithm I'm using appears to be producing the correct result...however I'm struggling with the file input. I never...
11
by: Peter Olcott | last post by:
Does C++ have anything like this?
2
by: Chris Riesbeck | last post by:
I assume the answer to this is "no" with no workarounds, but just checking. I have a page I open locally from my filesystem for "scrubbing" Microsoft Word generated junk from HTML. In Firefox 2,...
1
by: Sharad Singh | last post by:
I am new to Javascript/AJAX. I need to upload a file to a server using a file input element(using the 'onchange' event). I need to write a javascript/ajax code for the same. I would be very...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.