472,338 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 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 27661
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"> ...
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...
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?...
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...
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...
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...
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...
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=...
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...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.