468,315 Members | 1,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

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.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"> ??
Jul 23 '05 #1
1 27372
What Hermansen :o)

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

the answer is document.FORMNAME.ELEMENTNAME.value
Spam again :o)

"Jesper Hermansen" <no@spam.com> wrote in message
news:40*********************@dread11.news.tele.dk. ..
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">

??
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bhavin | last post: by
7 posts views Thread by Tim Slattery | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.