<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>get file input full path</title>
<script language='javascript'>
function getFullPath(obj)
{
if(obj)
{
//ie
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
obj.select()
return document.selection.createRange().text
}
//firefox
else if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
if(obj.files)
{
return obj.files.item(0).getAsDataURL()
}
return obj.value
}
return obj.value
}
}
</script>
</head>
<body>
<input type="file" onchange="document.getElementById('img').src=getFullPath(this)" />
<img id="img" />
</body>
</html>
firefox7+请使用return window.URL.createObjectURL(obj.files.item(0))来获取地址
先给图片标签<img>赋个ID如<imgid="s"/>
然后在JS里写document.getElementById("s").src=图片路径就可以了