By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.