2.获取file类型的文件名 <input type="file" id="<portlet:namespace />file0">
var filePath = document.getElementById("<portlet:namespace />file" + i + "").value;
var name = filePath.substring(filePath.lastIndexOf("\\") + 1,filePath.length );
var name1 = filePath.substring(filePath.lastIndexOf("\\") + 1,filePath.lastIndexOf(".") );
效果C:\Documents and Settings\zhuqingyu\桌面\test.doc
得到 test.doc 和test
js集合
最新推荐文章于 2024-11-20 09:00:00 发布
本文介绍了一种通过JavaScript获取HTML中input type=file元素所选文件名称的方法。具体实现了从完整路径中提取文件名及去掉扩展名的文件主体名称。
274

被折叠的 条评论
为什么被折叠?



