Click here to Skip to main content
14,332,494 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to get Full path from file control (Below code is not working in MOZILLA)

<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
Rate this:
Please Sign up or sign in to vote.

Solution 1

mention the value name property in the function.
function show_filename()
{
var filename = document.getElementById('text1').value;
alert(filename);
}
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

Input type is file.
your answer is OK with textbox but What about input type='file'
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

your HTML code format is invalid that's why i was confused. Anyway here is one
Get full path only in IE[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 8

I tried your code but problem is still there...
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100