Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Gone Erayd's Avatar
    Join Date
    Dec 2004
    Location
    Wellington, NZ
    Posts
    5,761

    Default HTML forms - filename without upload

    I'm having a not-so-small HTML problem with an app I am writing. I am wanting to offer the user a 'browse' box that they can use to choose a file on their machine, and then send the full name & path of the file (but not the file itself) to the server.

    I can do it with Javascript, but would like to avoid this if possible - it's a rather messy solution and doesn't degrade gracefully. Any ideas on how to do this in HTML?

    Cheers,
    Bletch

    [Edit: Would also be great if they could have the option of choosing a folder rather than a file]
    Last edited by Erayd; 26-10-2007 at 03:57 PM.
    If you are interested in reading fanfiction on a mobile device or ebook reader, please visit flagfic.com.

  2. #2
    Senior Member
    Join Date
    Nov 2006
    Posts
    1,927

    Default Re: HTML forms - filename without upload

    I just found this example - looks like it could be what you're wanting

    Code:
    <form action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"
    enctype="multipart/form-data" method="post">
    <p>
    Type some text (if you like):<br>
    <input type="text" name="textline" size="30">
    </p>
    <p>
    Please specify a file, or a set of files:<br>
    <input type="file" name="datafile" size="40">
    </p>
    <div>
    <input type="submit" value="Send">
    </div>
    </form>
    Just change the cs.tut.fi address (good for testing first tho) to your own and remove the text input paragraph if you dont want it

  3. #3
    pcsourcepoint
    Join Date
    May 2006
    Location
    Otara, Auckland
    Posts
    3,060

    Default Re: HTML forms - filename without upload

    I have tried the html code in my web site from bevy121 and it does display a form (in Frontpage 2000). I might test it on my server...
    Computer Tech Links (My Tutorials & Reviews)| Free MP3 Software Reviews (My Reviews)|I Student NZ (My Student Resoucre Tips)

  4. #4
    Gone Erayd's Avatar
    Join Date
    Dec 2004
    Location
    Wellington, NZ
    Posts
    5,761

    Default Re: HTML forms - filename without upload

    Quote Originally Posted by bevy121 View Post
    I just found this example - looks like it could be what you're wanting

    Just change the cs.tut.fi address (good for testing first tho) to your own and remove the text input paragraph if you dont want it
    This form will upload the file - which is exactly what I don't want. What I'm trying to do is just capture the filename and path, not the file itself.
    If you are interested in reading fanfiction on a mobile device or ebook reader, please visit flagfic.com.

  5. #5
    Senior Member
    Join Date
    Nov 2006
    Posts
    1,927

    Default Re: HTML forms - filename without upload

    ok sorry - this is prolly not a very good way of doing it, but if you change the enctype from "multipart/form-data" to the default "application/x-www-form-urlencoded" it only sends the text - being the filename
    as I say, prolly a terribly bad way of doing html, I know very little about it lol


    Code:
    <form action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi"
    enctype="application/x-www-form-urlencoded" method="post">
    <p>
    Type some text (if you like):<br>
    <input type="text" name="textline" size="30">
    </p>
    <p>
    Please specify a file, or a set of files:<br>
    <input type="file" name="datafile" size="40">
    </p>
    <div>
    <input type="submit" value="Send">
    </div>
    </form>
    The "sendback" script for the handler is here also if its of use to you

  6. #6
    Gone Erayd's Avatar
    Join Date
    Dec 2004
    Location
    Wellington, NZ
    Posts
    5,761

    Default Re: HTML forms - filename without upload

    I need the filename and the full path - not just the filename. The above approach sends only the filename.
    If you are interested in reading fanfiction on a mobile device or ebook reader, please visit flagfic.com.

  7. #7
    Senior Member
    Join Date
    Dec 2004
    Location
    Whangaparaoa
    Posts
    1,646

    Default Re: HTML forms - filename without upload

    irc?

  8. #8
    Senior Member
    Join Date
    Nov 2006
    Posts
    1,927

    Default Re: HTML forms - filename without upload

    Have you tried it?

    It sends the full path
    Last edited by bevy121; 27-10-2007 at 10:12 AM.

  9. #9
    Senior Member
    Join Date
    Nov 2006
    Posts
    1,927

    Default Re: HTML forms - filename without upload

    XP pro sp2 - IE 6

    even if user clicks a shortcut on their comp the full path will still be returned

    return data string using the above code


    Echoing submitted form data
    textline (empty)
    datafile C:\Documents and Settings\gdme\Desktop\test_file_for_path.txt

    Processed 2007-10-26T22:53Z

  10. #10
    Gone Erayd's Avatar
    Join Date
    Dec 2004
    Location
    Wellington, NZ
    Posts
    5,761

    Default Re: HTML forms - filename without upload

    Quote Originally Posted by bevy121 View Post
    Have you tried it?

    It sends the full path
    I have tried it - it doesn't send the full path for all the major browsers (notably Opera), which is what I need. Working in just one or two browsers isn't good enough.
    If you are interested in reading fanfiction on a mobile device or ebook reader, please visit flagfic.com.

Similar Threads

  1. filename footer
    By bpt2 in forum PressF1
    Replies: 3
    Last Post: 06-10-2006, 04:06 PM
  2. Replies: 2
    Last Post: 06-06-2002, 06:47 PM
  3. HTML and complex forms...
    By in forum PressF1
    Replies: 3
    Last Post: 06-06-2002, 10:54 AM
  4. HTML, Forms, Mailto, HELP
    By in forum PressF1
    Replies: 2
    Last Post: 14-02-2002, 11:04 PM
  5. filename
    By in forum PressF1
    Replies: 0
    Last Post: 25-09-1998, 11:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •