上传时获取文件的完整路径图片预览的js代码(兼容Firfox和IE)
http://www.lao8.org/article_1341/tougao
<html>
<head>
<title>get file input full path</title>
<script language='javascript'>
//alert(navigator.userAgent);
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>