Click here to Skip to main content
15,919,613 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get Full path from file control (Below code is not working in MOZILLA)

XML
<body>
<script type = "text/Javascript" >
function show_filename()
{
var filename = document.getElementById('eve').value;
alert(filename);
}
</script>
<form>
  <p>
  <input name="text1" type = "<strong class="highlight">file</strong>" id = "eve" size = "40" >
  </p>
  <p>
  <input type="Button" name="Submit" id="mybut" value="Submit" onclick="show_filename()" />
  </p>
</form>
</body>
Posted

mention the value name property in the function.
function show_filename()
{
var filename = document.getElementById('text1').value;
alert(filename);
}
 
Share this answer
 
v2
Input type is file.
your answer is OK with textbox but What about input type='file'
 
Share this answer
 
Hi,
I think I found your problem,
I just out a html file(input) control and a html button for submit ,than I tried to run it on IE ,it worked but when I tried to run it on mozilla firefox it didn't work because file control's name and id tags must be same .
this is my code block that is working on mozilla firefox too;




function show_filename() {
var filename=document.getElementById('fileupload').value; alert(filename);
<script/>

// my controls
<body>
<div>
<input id="fileupload" name="fileupload" type="file"/><br/>
<input id="button1" type="button" value="button" onclick="show_filename();" />
</div>
</body>



note: the important point is file control's name and id must be same.
note 2: if you want to find what's the problem with code , you can use firebug for firefox , you can watch your javascript from firebug's console.
Good luck.
 
Share this answer
 
your HTML code format is invalid that's why i was confused. Anyway here is one
Get full path only in IE[^]
 
Share this answer
 
I tried your code but problem is still there...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900