Using GetAbsolutePathName with File Input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grayscale

    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\Sys tem32\-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
    GetAbsolutePath Name 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.a sp"
    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.Creat eObject("Script ing.FileSystemO bject")
    name=Request.Fo rm("fname")
    path=fs.GetAbso lutePathName(na me)
    response.write( path)
    %>
    </body>
    </head>
    </html>

  • Mike Brind

    #2
    Re: Using GetAbsolutePath Name with File Input


    Grayscale wrote:[color=blue]
    > 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\Sys tem32\-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
    > GetAbsolutePath Name 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.a sp"
    > 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.Creat eObject("Script ing.FileSystemO bject")
    > name=Request.Fo rm("fname")
    > path=fs.GetAbso lutePathName(na me)
    > response.write( path)
    > %>
    > </body>
    > </head>
    > </html>[/color]

    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

    Comment

    • Grayscale

      #3
      Re: Using GetAbsolutePath Name with File Input

      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.OpenText File
      ("c:\Inetpub\ww wroot\record\da ta.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.OpenText File (-#-variable-#-, ForReading)

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

      Comment

      • Bob Barrows [MVP]

        #4
        Re: Using GetAbsolutePath Name with File Input

        Grayscale wrote:[color=blue]
        > 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.OpenText File
        > ("c:\Inetpub\ww wroot\record\da ta.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.OpenText File (-#-variable-#-, ForReading)
        >
        > The variable will be equal to selected file's path.[/color]

        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.


        Comment

        Working...