最简单的方法就是:
<input type="file" name="txt" value="">
<input type="file" name="txt" value="">
解决方案 »
- EXT问题卡主了。。。求助ing
- 在处理Object标签与Embed标签时思考的问题
- jquery:对于:$('div[ol]'),是什么意思呀
- 请高手给我详细解释下这个js
- 浏览器对于js文件的缓存策略是什么?有什么办法可以在html中控制缓存吗?
- js window.open 如何控制连续点击同一个超链接 弹出多个窗口
- 怎样在javascript中校验输入是否为数字,字符,整数等类型
- 怎样去掉IE的工具栏和地址栏?
- 我在一个框架中处理一个页面的提交,默认是提交到自己所在的框架,但我想提交到父框架,可不可以
- 为啥火狐在作跨域时,必须要创建一个script标签呢
- 寻找一个js时间控件
- 如何判断文本域中选择了那些文字?
<head>
<title>file</title>
<Script language="javascript">
<!--
function fncFile(val)
{
re = new RegExp(/\\/);
val.match(re);
var start=re.lastIndex;
var end=val.length;
document.form1.txt.value=val.substr(start,end);
}
//-->
</Script><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<form name="form1">
PATH:<input type="file" name="fil" value="" onchange="fncFile(this.value)">
FILENAME:<input type="text" name="txt" value="" >
</form>
</body>
</html>
<html>
<head>
<title>file</title>
<Script language="javascript">
<!--
function fncFile(val)
{
var sArray=val.split("\\");
for(i=0;i<sArray.length;i++)
{
s=sArray[i];
}
document.form1.txt.value=s;
}
//-->
</Script><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<form name="form1">
PATH:<input type="file" name="fil" value="" onchange="fncFile(this.value)">
FILENAME:<input type="text" name="txt" value="" >
</form>
</body>
</html>
这个是不用循环的,上边的代码是我搞错了(光想着整则表达式了)!
<html>
<head>
<title>file</title>
<Script language="javascript">
<!--
function fncFile(val)
{
var end=val.length
var start=val.lastIndexOf("\\")+1;
document.form1.txt.value=val.substr(start,end);
}
//-->
</Script><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<form name="form1">
PATH:<input type="file" name="fil" value="" onchange="fncFile(this.value)">
FILENAME:<input type="text" name="txt" value="" >
</form>
</body>
</html>
var tempArray = new Array( );function GetFileName( Path ) {
var tempLenght = 0;
tempArray = Path.split("\\");
tempLenght = tempArray.length;
alert(tempLenght);
document.all.fileName.value = tempArray[tempLenght-1];
}
</script>
<input type="file" name="filePath" value="" onChange="GetFileName( this.value )">
<input type="text" name="fileName" value="">