Get '<input type="file">.value' with Internet Explorer

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

    Get '<input type="file">.value' with Internet Explorer

    Hi!

    I'm making a system that will generate Winamp-playlists.
    To make it easy for the user to add a file to the list, I'm using <input
    type="file">.

    The problem with this is that I only get the filename, not the path,
    which is necessary in my situation.

    I cracked the problem in Firefox:

    <snip>
    function get_id ($id) {
    if (document.all && document.getEle mentById) {
    return document.all($i d);
    } else if (!document.all && document.getEle mentById) {
    return document.getEle mentById($id);
    } else {
    return false;
    }
    }


    function fullpath () {
    $file = get_id('file');
    $hiddenfile = get_id('hiddenf ile');
    $hiddenfile.val ue = $file.value;
    }

    <form action="save.ph p" method="post" onsubmit="fullp ath();">
    File: <input id="file" type="file" />
    <input type="hidden" name="file" id="hiddenfile " />
    <input type="submit" value="Add" />
    </form>

    </snip>

    But this doesn't seem to work in Internet Explorer and Opera...

    Is there another way to get the absolute path from an <input type="file"> ??
  • Grunken

    #2
    Re: Get '&lt;input type=&quot;file &quot;&gt;.valu e' with Internet Explorer

    What Hermansen :o)

    I'm not the only Dane using this group :o)

    the answer is document.FORMNA ME.ELEMENTNAME. value


    Spam again :o)



    "Jesper Hermansen" <no@spam.com> wrote in message
    news:40878c3f$0 $168$edfadb0f@d read11.news.tel e.dk...[color=blue]
    > Hi!
    >
    > I'm making a system that will generate Winamp-playlists.
    > To make it easy for the user to add a file to the list, I'm using <input
    > type="file">.
    >
    > The problem with this is that I only get the filename, not the path,
    > which is necessary in my situation.
    >
    > I cracked the problem in Firefox:
    >
    > <snip>
    > function get_id ($id) {
    > if (document.all && document.getEle mentById) {
    > return document.all($i d);
    > } else if (!document.all && document.getEle mentById) {
    > return document.getEle mentById($id);
    > } else {
    > return false;
    > }
    > }
    >
    >
    > function fullpath () {
    > $file = get_id('file');
    > $hiddenfile = get_id('hiddenf ile');
    > $hiddenfile.val ue = $file.value;
    > }
    >
    > <form action="save.ph p" method="post" onsubmit="fullp ath();">
    > File: <input id="file" type="file" />
    > <input type="hidden" name="file" id="hiddenfile " />
    > <input type="submit" value="Add" />
    > </form>
    >
    > </snip>
    >
    > But this doesn't seem to work in Internet Explorer and Opera...
    >
    > Is there another way to get the absolute path from an <input type="file">[/color]
    ??


    Comment

    Working...