<input id="FileUpload" type="file" style="width:448px; height: 22px;"
onclick="return FileUpload_onclick()" onchange="return FileUpload_onselect()"/>
<script type="text/javascript" language="javascript">
function FileUpload_onselect()
{
var path;
path=document.forms[0].FileUpload.value; //C:\Documents and Settings\hud\桌面\AddFile.jpg
var aa;
aa=path.split('.');
document.all('TbxName').value=aa[aa.length-1]; //jpg 结果
var name;
name=path.split('\\');
var bb=name[name.length-1];
document.all('Tbx_FileName').value=bb.substr(0,bb.indexOf('.')); //AddFile 结果
}
</script>
来源:https://www.cnblogs.com/hyd309/archive/2008/09/22/1295895.html