473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 27832
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bhavin | last post by:
Hi I'm trying to set default value for input type file. <input type="File" name="tx_pdffile" accept="*.pdf" class="boxText" value="abc.pdf"> but this value (abc.pdf) doesnt appear in the text...
2
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds...
2
by: Laermans_k | last post by:
Hi, Does anyone have a solution to use the <input type="file" id="filechooser"> and the <input type="submit" id="submitbutton"> in 1 button click? I've already tried to create a javascript...
7
by: Drew Berkemeyer | last post by:
I've encounted a pretty strange problem and I'm not quite sure what to make of it. I have a web service that consumes an XML file as well as a few other parameters. This web service works fine...
2
by: Tarkeshwar | last post by:
Hi All, I want to restrict the user from being entering the value in <input type="file">. It works fine in IE but not in Mozilla. I am sending my code also which works in IE and not in Mozilla.Can...
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
3
by: eeeeman | last post by:
This one has really got me! Im trying to write a value to a input type="file" form element using client-side javascript. I have tried the obvious, simply writing: <input type="file" ...
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
1
by: sandeep kumar shah | last post by:
Hi, We have used a file uploading HTML tag in an HTML page. We need to customize the text displayed on the Button (which is by default “Browse…” for internet explorer). Below is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.