提取图片文件名
C:\Documents and Settings\Administrator\My Documents\My Pictures\样品
我现在一提取这样,现在要去文件名,比如“样品”
要什么写啊
function preview4()//本地判断图片名称
{
var x = document.getElementById("file4");
var y = document.getElementById("pic4");
if(!x || !x.value || !y) return;
var patn = /\.jpg$|\.jpeg$|\.gif$/i;
if(patn.test(x.value))
{
str=x.value;
re = /\..*/;
str1=str.replace(re,"");
//var r = /\./;
y.value= str1
}
else
{
alert("您选择的似乎不是图像文件。");
}
}