ok.
here's an example form and javascript which will work.
<html>
<head>
<script type="text/javascript">
function get_file_name()
{
var frm = document.test; //change this to the name of your form
var str_filename = frm.file.value; //change this to the name of your file upload control
if(str_filename != "")
{
last_pos = str_filename.lastIndexOf("\");
var file_name = str_filename.substring((last_pos+1),str_filename.length);
}
//store the filename in the hidden field
frm.thefilename.value = file_name;
//submit the form
frm.submit();
}
</script>
</head>
<body>
<form name="test" id="test" action="somefile.php" method="POST">
<input type="file" name="file">
<input type="hidden" name="thefilename">
<input type="button" value="Submit" onClick="get_file_name();">
</form>
</body>
</html>