reading the input type=file tag with ie6 in asp

Discussion in 'ASP General' started by Joel Goldstick, Sep 25, 2003.

  1. I wanted to write a simple page to let me choose a directory and then list
    the files in it. The end goal was to make an easy way to copy all the
    file names in a directory. I tested with Opera7, Mozilla 1.4 and IE6 -- all
    on windows XP Pro


    Here is the code. In all three, when I select a file, the complete path
    is displayed in the file input box. In Opera, reading the form field gives
    me the same full path. But in IE and Moz I get only the filename -- none of
    the path information.



    Any ideas how to salvage this?



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    <html
    <head<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
    <titleColumbusWebMakers.com-ListDirectory</title
    <link href="../css/columbuswebmakers.css" type="text/css"
    rel="stylesheet"
    </head
    <body
    <div id="banner"
    <h1<a href= "../index.html"ColumbusWebMakers.com</a</h1
    <pExperienced WebSite design and construction</p
    </div
    <div id="Content"<pThis page lets you display all of the filenames in a
    directory. You can then highlight those names and copy them for use in
    another application. First, select any file in the directory you wish to
    display. Then press submit.
    </p
    <form action="" method="post"
    <input type="file" id ="FileList" name = "FileList"
    <input type="submit"
    </form
    <%
    function ListFiles()
    dim fso, folder, files, f
    dim sFiles, i, strFolderName

    sFiles = ""
    i = Request.Form.Count
    for j = 1 to i
    strLabels = strLabels & request.form.key(j) & ": " &
    Request.Form.item(j)
    & ", "
    next
    Response.write strLabels & vbCRLF

    strFolderName = request.form.item("FileList")
    if (strFolderName < "") then
    set fso=CreateObject("Scripting.FileSystemObject")
    lastSlash = instrrev(strFolderName,"\")
    response.write "<pLooking for files in " & strFolderName & "</p"
    strFolderName = mid(strFolderName, 2, lastSlash - 1)
    response.write "<pLooking for files in " & strFolderName & "</p"
    set folder= fso.getFolder(strFolderName)
    set files = folder.files

    for each f in files
    sFiles = sFiles & f.name & "<br"
    next
    response.write "<p" & sFiles & "</p"
    end if

    ListFiles = sFiles
    end function

    ListFiles

    %</div
    </body
    </html




    --
    Joel Goldstick
    http://www.ColumbusWebMakers.com
     
    Joel Goldstick, Sep 25, 2003
    #1
    1. Advertising

  2. Joel Goldstick

    Ray at Guest

    1. Where are all your >'s?
    2. You realize that this could only possibly work if you're browsing on the
    webserver itself, yes?
    3. The file input is for uploading a file from the client to the server.

    Ray at home

    "Joel Goldstick" <> wrote in message
    news:...
    >
    >
    > I wanted to write a simple page to let me choose a directory and then

    list
    > the files in it. The end goal was to make an easy way to copy all the
    > file names in a directory. I tested with Opera7, Mozilla 1.4 and IE6 --

    all
    > on windows XP Pro
    >
    >
    > Here is the code. In all three, when I select a file, the complete path
    > is displayed in the file input box. In Opera, reading the form field

    gives
    > me the same full path. But in IE and Moz I get only the filename -- none

    of
    > the path information.
    >
    >
    >
    > Any ideas how to salvage this?
    >
    >
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd"
    > <html
    > <head<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
    > <titleColumbusWebMakers.com-ListDirectory</title
    > <link href="../css/columbuswebmakers.css" type="text/css"
    > rel="stylesheet"
    > </head
    > <body
    > <div id="banner"
    > <h1<a href= "../index.html"ColumbusWebMakers.com</a</h1
    > <pExperienced WebSite design and construction</p
    > </div
    > <div id="Content"<pThis page lets you display all of the filenames in a
    > directory. You can then highlight those names and copy them for use in
    > another application. First, select any file in the directory you wish to
    > display. Then press submit.
    > </p
    > <form action="" method="post"
    > <input type="file" id ="FileList" name = "FileList"
    > <input type="submit"
    > </form
    > <%
    > function ListFiles()
    > dim fso, folder, files, f
    > dim sFiles, i, strFolderName
    >
    > sFiles = ""
    > i = Request.Form.Count
    > for j = 1 to i
    > strLabels = strLabels & request.form.key(j) & ": " &
    > Request.Form.item(j)
    > & ", "
    > next
    > Response.write strLabels & vbCRLF
    >
    > strFolderName = request.form.item("FileList")
    > if (strFolderName < "") then
    > set fso=CreateObject("Scripting.FileSystemObject")
    > lastSlash = instrrev(strFolderName,"\")
    > response.write "<pLooking for files in " & strFolderName & "</p"
    > strFolderName = mid(strFolderName, 2, lastSlash - 1)
    > response.write "<pLooking for files in " & strFolderName & "</p"
    > set folder= fso.getFolder(strFolderName)
    > set files = folder.files
    >
    > for each f in files
    > sFiles = sFiles & f.name & "<br"
    > next
    > response.write "<p" & sFiles & "</p"
    > end if
    >
    > ListFiles = sFiles
    > end function
    >
    > ListFiles
    >
    > %</div
    > </body
    > </html
    >
    >
    >
    >
    > --
    > Joel Goldstick
    > http://www.ColumbusWebMakers.com
    >
    >
     
    Ray at, Sep 25, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  2. Ivor O'Connor
    Replies:
    4
    Views:
    875
    Isofarro
    Nov 25, 2003
  3. Peter Mount
    Replies:
    4
    Views:
    975
    Peter Mount
    Jan 31, 2006
  4. Randell D.
    Replies:
    12
    Views:
    264
    Randell D.
    Jul 6, 2005
  5. Pugi!
    Replies:
    0
    Views:
    246
    Pugi!
    Feb 5, 2007
Loading...

Share This Page