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

J

Jesper Hermansen

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.getElementById) {
return document.all($id);
} else if (!document.all && document.getElementById) {
return document.getElementById($id);
} else {
return false;
}
}


function fullpath () {
$file = get_id('file');
$hiddenfile = get_id('hiddenfile');
$hiddenfile.value = $file.value;
}

<form action="save.php" method="post" onsubmit="fullpath();">
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"> ??
 
G

Grunken

What Hermansen :eek:)

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

the answer is document.FORMNAME.ELEMENTNAME.value


Spam again :eek:)



Jesper Hermansen said:
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.getElementById) {
return document.all($id);
} else if (!document.all && document.getElementById) {
return document.getElementById($id);
} else {
return false;
}
}


function fullpath () {
$file = get_id('file');
$hiddenfile = get_id('hiddenfile');
$hiddenfile.value = $file.value;
}

<form action="save.php" method="post" onsubmit="fullpath();">
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">
??
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top